![]() |
| | #1 |
| Registered User Join Date: Sep 2009
Posts: 5
| Syntax error, please help. "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;
}
|
| Bumps is offline | |
| | #2 |
| Registered User Join Date: Jun 2008
Posts: 1,134
| Code: void printarray (); |
| C_ntua is offline | |
| | #3 |
| Registered User Join Date: Sep 2009
Posts: 5
| damn that was to easy. Thanks |
| Bumps is offline | |
| | #4 |
| Registered User Join Date: Sep 2009
Posts: 10
| 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. |
| C_Sparky is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| what am I missing? (Program won't compile) | steals10304 | C Programming | 3 | 08-25-2009 03:01 PM |
| more then 100errors in header | hallo007 | Windows Programming | 20 | 05-13-2007 08:26 AM |
| We Got _DEBUG Errors | Tonto | Windows Programming | 5 | 12-22-2006 05:45 PM |
| Using VC Toolkit 2003 | Noobwaker | Windows Programming | 8 | 03-13-2006 07:33 AM |
| Dikumud | maxorator | C++ Programming | 1 | 10-01-2005 06:39 AM |