#include<stdio.h>
void main() {
int a[3];
a[0]=1;
a[1]=2;
a[2]=3;
printf("%d", a[2]);
}
It isn't showing any errors or warnings. But it isn't running
#include<stdio.h>
void main() {
int a[3];
a[0]=1;
a[1]=2;
a[2]=3;
printf("%d", a[2]);
}
It isn't showing any errors or warnings. But it isn't running
void main(){
is non-standard. main()
function should return an int
. Some IDEs/platforms check the return the value of the process. So this might be a problem.
Change it to:
int main(void){
If you are using C89 then you should also have a return statement from main()
. This is not required since C99. In C99 and later, main()
will implicitly return success if the control reaches the end of main as if you had: return 0;
at the end of main()
function.
In C89/C90, you must have a return 0;
or return EXIT_SUCCESS;
at the end of main()
. Otherwise, it leads to undefined behaviour. But this is not required in C99 and C11. There's obviously no other problem in your code except this. So if you still have issues, you need to provide more details about your environment/compiler.