void error
i want to ask, why in following code, an error "line 5 : `main' must return `int'" ..?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <iostream>
using namespace std;
void main()
{
int x[]={4,2,8,9,3,12,5,0,14,1};
int count=0, largest=0;
while (count !=0)
{
if (x[count]>largest)
{
largest=x[count];
count=count+1;
}
}
cout<<largest;
system("PAUSE");
}
|
so, main()
can only use "int"
?
That's correct.
Some compilers allow the return type of main to be void, but it's not Standard C++.
Topic archived. No new replies allowed.