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 9003339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:41:57+00:00 2026-06-16T00:41:57+00:00

I pass 3 strings to the function and need look through the strings to

  • 0

I pass 3 strings to the function and need look through the strings to find a word that appears in all three of them. The strings are just letters with no spaces or interpunction. I wrote a code to go through 2 strings but it doesn’t work for some reason. Any help is appreciated.

char* najduljiPodniz(char* niz1, char* niz2, char* niz3)
{
   int i,j,t1,br=0;

   for(i=0;i<strlen(niz1);i++)
   {
       for(j=0;j<strlen(niz2);j++)
       {
           if(niz1[i]==niz2[j])
           {
               t1=i;
               br++;
               while(niz1[i]==niz2[j])
               {
                   br++;
                   i++;
                   j++;
               }
           }
           else break;
       }
   }

char *podniz=(char*)malloc(sizeof(char)*br+1);

for(i=0,j=t1;j<br;i++,j++)
    podniz[i]=niz1[j];

for(i=0;i<br;i++)
    printf("%s",podniz[i]);

return 0;
}

For clarification: Example of a string would be: “afsdmartiangknrhg”. So, random letters and somewhere in the string there’s an actual word. In this example “martian”. The other 2 strings also contain the word “martian”. The word martian is “unkown” to me so I can’t check for that actual word in the string.

  • 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-16T00:41:58+00:00Added an answer on June 16, 2026 at 12:41 am

    OK, here’s my new answer based on the revised description of the problem (see the comments on my first answer).

    First, choose the shortest of the three strings. Iterate over all possible substrings of this string, starting with the longest. For each substring, use strstr to search for it in the other two strings. If it’s found in both, you have your solution.

    Try something like:

    for (i=0; i<N; i++) {
        for (j=0; j<=i; j++) {
            int tmp = a[N-1-i+j];
            a[N-1-i+j] = 0;
            if (strstr(b, a+j) && strstr(c, a+j)) printf("got '%s'\n", a+j);
            a[N-1-u+j] = tmp;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to pass strings that may contain special characters to a Javascript function
I need to pass a string literal to a function myfunction(arg1 DEF_CHAR arg1); now
I want to be able to pass a string (['parent_array']['child_array']) to a function that
I have some data that I need to pass to JavaScript on a page.
I need to encrypt a string using MySQL's AES_ENCRYPT function, then attach that encrypted
I need to write a function to find the first non-repeating character in a
I have this simple function which I pass in an array of strings: function
I need to pass 4 arguments (3 strings and one comma separated list) from
I need to pass an array of strings as parameter to a MySQL stored
I want to create a function that receive multiples strings as parameters. Like the

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.