C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-08-2009, 12:11 PM   #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;

}
Bumps is offline   Reply With Quote
Old 11-08-2009, 12:19 PM   #2
Registered User
 
C_ntua's Avatar
 
Join Date: Jun 2008
Posts: 1,134
Code:
void printarray (); 
C_ntua is offline   Reply With Quote
Old 11-08-2009, 12:48 PM   #3
Registered User
 
Join Date: Sep 2009
Posts: 5
damn that was to easy. Thanks
Bumps is offline   Reply With Quote
Old 11-09-2009, 09:29 PM   #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   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 06:08 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

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