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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:29:45+00:00 2026-05-21T02:29:45+00:00

I am learning C and this might be a trival question to some. My

  • 0

I am learning C and this might be a trival question to some.

My IDE complaints that there is an error: expected expression before ‘!=’ token in the while loop.

I can’t see any problem with that, any suggestions?

  /* Print a file to the console, line by line. */
  FILE *fp_infile;
  char linebuffer[512];

  if (( fp_infile=fopen("input.dat", "r")) == NULL )
    {
      fprintf(stderr, "Couldn't open input file.\n");
      return -1;
    }

  while ( fgets( linebuffer, sizeof(linebuffer), fp_infile )) != NULL ) // ERROR
    fputs( linebuffer, stdout );

    if ( ! feof(fp_infile) )   // This means "if not end of file"
      fprintf( stderr, "Error reading from input file.\n" );

      if ( fclose(fp_infile) != 0 )
        {
          fprintf(stderr, "Error closing input file.\n");
          return -2;
        }
  • 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-05-21T02:29:45+00:00Added an answer on May 21, 2026 at 2:29 am

    You have a parenthesis mismatch error. Count the number of ( and compare to the number of ).

    The line should probably be:

    while (fgets(linebuffer, sizeof linebuffer, fp_infile) != NULL)
    

    Note that you only need parens with sizeof when required by the argument’s syntax; sizeof itself is an operator, not a function.

    My manual and very kindergarten-like way of matching parenthesis, is to simply scan the line from left to right, while maintaining a count:

    • Start at 0
    • When you find a (, increase the count
    • When you find a ), decrease the count

    When you reach the end of the line, if the count isn’t back to 0, you have a mismatch. Very obvious, but quite efficient to quickly determine the existence of a mismatch.

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

Sidebar

Related Questions

I am learning some WPF/C# so this question might be silly for some of
This question might seem very specific but I am in need of some ideas
This might be a silly question but I am still learning. I have read
I've just started learning jQuery/javascript, so this might seem like a really basic question,
This might be a stupid question but I am learning about SQLCMD and the
I realise that this might be a stupid question, but I have not come
I realize that this might be a duplicate question but this question is very
this is my second week of learning SQL it might be an easy question
I'm learning this right now so the questions might be a little juvenile. Here's
Ok I am still learning this... I have Googled and done some research but

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.