Thread: HELP - error: expected expression before â=â token

  1. #1
    Registered User
    Join Date
    Oct 2014
    Posts
    15

    HELP - error: expected expression before â=â token

    So I have the following gist in my code...
    Code:
    long long getint(long long min, long long max)
    {  
     long long x;
     int rc, again = 1;
     char after;
     do
     { 
     printf("Enter an integer [0..10]: ");
     rc = scanf("%d%c", &x, &after);
      if (rc == 0)
      {
       printf("No valid input. Try again.\n");
       myclear();
      }
      else if (after != '\n')
      {
       printf("Trailing character. Try again.\n");
       myclear();
      }
      else if (x < min || x > max)
      {
       printf("Out of range. Try again.\n");
       myclear();
      }
      else // valid input
      {
       again = 0;
      }
     } while (again == 1);
     return x;
    }     
    
    .... 
    
    double getfloat(double min, double max)
    {
     int rc, again = 1;
     double x;
     char after;
     do
     {
     printf("Enter an integer [0..10]: ");
     rc = scanf("%d%c", &x, &after);
      if (rc == 0)
      {
       printf("No valid input. Try again.\n");
       myclear();
      }
      else if (after != '\n')
      {
       printf("Trailing character. Try again.\n");
       myclear();
      }
      else if (x < min || x > max)
      {
       printf("Out of range. Try again.\n");
       myclear();
      }
      else // valid input
      {
       again = 0;
      }
     } while (again == 1);
     return x;
    }
    
    ...
    
    for (counter = 0; counter <100; counter ++)
     {
      printf ("ISBN    :  ");
      ISBN[counter] = getint(MIN, MAX);
      
      if (ISBN[counter] == 0)
       {
       counter == 99;
       }
     
      printf ("Price    :  ");
      PRICE[counter] = getfloat(MIN1, MAX1);
       
      printf ("Quantity :  ");
      QUANTITY[counter] = getint (MIN, MAX);
    }
    I keep getting an "expected expression before â=â token" on the 'array = input' sections every time I try to compile. Any help?

  2. #2
    Registered User
    Join Date
    Oct 2014
    Posts
    15
    Oops, solved it .

  3. #3
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,106
    You have not provided the whole program. Where is the main() function? We can't compile it to see the actual compile error(s). Please repost the entire code, or at least a stripped down version that can replicate the error.

  4. #4
    Registered User
    Join Date
    Oct 2014
    Posts
    15
    How do lock the thread? I don't see how. Can a mod do it? Thanks.

  5. #5
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    You should post your solution so others might benefit from it.

    Code:
    if (ISBN[counter] == 0)
    {
        counter == 99;
    }
    This doesn't do what you think it does.

    How do lock the thread? I don't see how. Can a mod do it? Thanks.
    Threads aren't usually locked when they're solved. Just let the thread run its course.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. error : expected primary-expression before ']' token
    By funnydarkvador in forum C Programming
    Replies: 8
    Last Post: 02-20-2013, 07:06 PM
  2. error : expected primary-expression before ']' token
    By funnydarkvador in forum C++ Programming
    Replies: 8
    Last Post: 02-20-2013, 07:06 PM
  3. Replies: 10
    Last Post: 08-09-2012, 12:48 PM
  4. error: expected expression before ‘{’ token
    By nendariani in forum C Programming
    Replies: 7
    Last Post: 09-14-2008, 11:27 AM
  5. Replies: 7
    Last Post: 09-14-2008, 08:37 AM