Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8992891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:03:52+00:00 2026-06-15T23:03:52+00:00

My goal is to call a function and the function will return me 0

  • 0

My goal is to call a function and the function will return me 0 / 1 if the sent string has the
sent substring in it , I do not need to find its index
for example:

String : “Hello World”
SubString : “rl”
will return 1

String : “asssbdsd”
SubString : “ab”
will return 0

so I’ve come up with this solution :

int HasSubstr(char* mainStr, char* subStr)
{
    if (!*subStr)
    {
        return 1;
    }
    if (!*mainStr)
    {
        return 0;
    }
    if (*mainStr == *subStr)
    {
        return HasSubStr(mainStr + 1, subStr + 1);
    }
    else
    {
        while(*(subStr -1))
        {
            subStr--;
        }
        return HasSubStr(mainStr + 1, subStr);
    }
}

but it’s not a pure recursion and i need it to be a pure recursion
, help would be much applied

Yes this is homework

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:03:53+00:00Added an answer on June 15, 2026 at 11:03 pm

    Don’t try to fit it all within one function.

    int StartsWith(const char *mainstr,const char *subStr)
    {
      if (*subStr == '\0') return 1;
      if (*mainStr != *subStr) return 0;
      return StartsWith(mainStr+1,subStr+1);
    }
    
    int HasSubstr(const char *mainStr,const char *subStr)
    {
      if (StartsWith(mainStr,subStr)) return 1;
      if (*mainStr == '\0') return 0;
      return HasSubstr(mainStr+1,subStr);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My goal is to submit an entire form through an ajax function which will
Need urgent help on thread: the goal here is the separtemask will take each
Possible Duplicate: How to force child same virtual function call its parent virtual function
My goal is to be able to call functions that are inside my JQuery
my goal is to create a sort of Javascript library, if you could call
I'd like to call something like usleep() inside a CUDA kernel. The basic goal
Goal: Gain datatype date with year and month Problem: Need to help to convert
I have a getStockQuote() function that will get a current stock quote for a
I have a simple AJAX call that is querying the Twitter API to return
Note: I do NOT want to use any framework. The goal is just to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.