Syntax error, please help.

This is a discussion on Syntax error, please help. within the C++ Programming forums, part of the General Programming Boards category; I started out with 15 errors and worked them all out except for this one. "error C2144: syntax error : ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    5

    Syntax error, please help.

    I started out with 15 errors and worked them all out except for this one.
    "error C2144: syntax error : 'int' should be preceded by ';'"

    it points to my int main ()

    I tried look for any missing ";" but cant find any.

    Would any one mind taking a look?
    It a program filling a random number in all the array locations and asking user to enter an integer (between 0 and 9) and we are supposed to print score.

    Code:
    // pointer to arrays
    
    #include <iostream>
    #include <ctime>
    
    using namespace std;
    
    void printarray ()
    
    int main ( )
    {
       int score [10];
       int *ptr;
       int userint = 0;
    
      ptr = &score[0]; //ptr poinst to the integer array of "score"
    
      srand(time(NULL)); ////makes use of the computer's internal clock to control the choice of the seed. 
    
    //for loop will loop filing with random numers between 0 and 50 
      for (int i = 0; i < 10; i++)
      {
    	*ptr = rand()%50;
    	++ptr;
      }
    
    	cout << "Enter a number between 0 and 9: " ;
    	cin >> userint;
    	//if else stament determines if use data is between 0 and 9
    	if (userint >= 0 && userint <= 9)
    		cout << score[userint] << endl;
    	else if (userint > 10 )
    		cout <<"You must enter a number between 0 and 9, Please try again." << endl;
    
      system ("pause");  
      return 0;
    
    }

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Code:
    void printarray ();

  3. #3
    Registered User
    Join Date
    Sep 2009
    Posts
    5
    damn that was to easy. Thanks

  4. #4
    Grey Wizard C_Sparky's Avatar
    Join Date
    Sep 2009
    Posts
    50
    Yeah when it gives an error like that and the line it's on looks good always check the line before it, it is usually a semicolon or parenthesis error.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what am I missing? (Program won't compile)
    By steals10304 in forum C Programming
    Replies: 3
    Last Post: 08-25-2009, 03:01 PM
  2. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  4. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 06:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21