-
expected identifier
Hi, I've been playing around with this idea of program which probably has been made already million times but i cant get mine working for some reason, its supposed to write numbers 1 to 10000 for now just with printf, but the idea is to get it to write it to textfile and in format: 00000 00001 00002 00003 and so on...
Code:
#include <stdio.h>
int ruu = 10000;
int var = 0;
while (var <= ruu)
{
printf(var);
var++;
}
my compiler says:
error: expected identifier or '(' before 'while'
Compilation failed.
also, I'm on ubuntu 10.04 using Geany.
-
No main procedure?
Code:
#include <stdio.h>
int main (void) {
int ruu = 10000;
int var = 0;
while (var <= ruu)
{
printf("%i\n", var);
var++;
}
}
-
Now it compiles but still gives:
in function 'main':
warning: control reaches end of void function
what does this mean?
-
He did not explicitly add a return statement. Under C99, this is ok, but under C89, you must include a return:
Code:
#include <stdio.h>
int main (void) {
int ruu = 10000;
int var = 0;
while (var <= ruu)
{
printf("%i\n", var);
var++;
}
return 0;
}
-
Put a return 0 at the end too.
-
Thanks alot for the help, now it compiles and builds with no errors or warnings, it worked fine before adding the "return 0" but i prefer to learn these things properly :)