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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:42:16+00:00 2026-06-11T20:42:16+00:00

I am working in an assignment and am experiencing some weird stuff. I have

  • 0

I am working in an assignment and am experiencing some weird stuff. I have this while loop in my program that does not seem to branch into the for loop. I have placed two print statements and only the “1” prints over and over again. Note that this only happens when I compile and run from the linux terminal. Now what seem weird is that if i run the exact same code (while loop plus everything else) in Netbeans it seems to compile and behave as expected. Anyone know what might be wrong. Here is the code. I appreciate your help.

while(strstr(p,string_a)!= NULL)
{
    p = trailerp + pholderp; 
    long int index =  strstr(p,string_a) - (p+1); // -1 where it hits 
    printf("1");
    for(  i = 0; i <= index; i++)
    {
        printf("2");
        p2[trailerp2] = pholderp[trailerp];
        trailerp++;
        trailerp2++;
        if(i == index)
        {  
            int j;
            for(j=0; j <= lenb-1; j++)            // insert the new string
            {
                p2[trailerp2] = string_b[j];
                trailerp2++;
            }
            trailerp++;
        }       
    }  
}    

Edit: I have found the problem. Netbeans seems to be broken in this OS.

  • 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-11T20:42:17+00:00Added an answer on June 11, 2026 at 8:42 pm

    This is because strstr(p,string_a) returns either p or 0 in this part:

    long int index =  strstr(p,string_a) - (p+1); // -1 where it hits 
    

    which results in index < 0 and prevents going into the loop.

    You must print both p and string_a immediately before this statement to see what is going wrong there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i`m working on my assignment for univ, and since some parts are not really
I'm currently working on an assignment and this have had me stuck for hours.
I am working on an assignment with polymorphism and have followed online tutorials that
Currently I'm working on an assignment that requires that I create a program in
I am working on an assignment which to create a program that can read
I'm working on an assignment that is telling me to assume that I have
I am working on an assignment that specified Do not use any external libraries.
While I was working on an assignment, I came to know that we should
I am working on an assignment that deals with storing and sorting some data.
I'm working on my assignment of PHP course. The problem that I don't understand

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.