GP32 Help....learning Going Wrong


Jan 19, 2004
Donny, England (follow signs that say craphole)
K been using a guide on how to code in C and i have been doing simple programs that it states to show how different functions work, such as:

#include <stdio.h>
#define MAX 10

int main ()
int x;
f=fopen("out", "w") ;
if (!f)
return 1 ;
for(x=1; x<=MAX; x++)
fprintf(f,"%d\n" ,x) ;
fclose (f) ;
return 0 ;

Its just that my compiler says i have a missing prototype for main.
Well, the code looks OK. What compiler are you using?

You don't have to supply a prototype for main as it is pre-defined.

The actual correct declaration for main() is
int main ( int argc, char * argv[] )
so maybe you should try that. You'll probably get warnings for "unused variables argc and argv" but you can ignore them.
You should always say "int main(void)"
the above declaration is for windows programs i think (it is right ?)
but then you should use "include <windows.h>"

But otherwise, i don't see why the main should be wrong.
TeDaDeS: No, you're not right ;)
The main function for a Windows program is WinMain and it takes more parameters. int main (void) is OK for most compilers, but it's not correct. Often void main (void) is acceptable too.

Splinter: I never new Pelles C existed - it's a pretty impressive looking piece of work!

At the start of your project, did you specify it as a "Win32 console application (EXE)"? That's what you need for the sort of program you're making.

You'll need to give more details about what "does not run" means. Perhaps it did run, but it was over so quickly that you didn't see it? Try putting a breakpoint in it somewhere, or running it from a command prompt.