I'm studying for an exam and trying the practice problem in the book. I keep getting an error with a void fctn, the code is below:
void readdata(int num[], int &n)
{
cout << "Enter the number of marks> ";
cin >> n;
if (n > 0 && n <= SIZE)
cout << "There are " << n << " marks" << endl;
else {
cout << "Invalid number of marks" << endl;
exit(1);
}
for (int count = 0; count < n; count++) {
cout << "Enter a mark> ";
cin >> num[count];
cout << num[count] << endl;
}
return;
}
This is the error msg:
E:\Users\...\Practice Programs\20111104_Prog7.cpp||In function 'void readdata(int*, int&)':| <--- HA! my error msg is not happy with me!
E:\Users\...\Practice Programs\20111104_Prog7.cpp|41|error: 'exit' was not declared in this scope|
What am I doing wrong? I'm litterally copying code from the book and didn't make any mistakes in that sense. Also, I'm very new to programming so I've done all that "my" programming allows me to do.
Thanks in advance!