0
#include<stdio.h>
void main()
{ 
    int i = -1, j = 1,k,l;
    k=!i&&j;
    l= !i||j;
    printf("\n%d\n%d",i,j);
}

shows in output: Runtime error time: 0 memory: 10304 signal:-1

but if i replace void by int and add return 0 in program it works fine without any error why?

  • 4
    `void main()` is not a standard signature for `main`. It might work with *some* compilers. The only signatures guaranteed by the standard are `int main(void)` and `int main(int, char**)`. –  Jul 02 '17 at 07:35

1 Answers1

0

void main() is not described in the C11 Standard. Some implementations are free to "legalize" it. The implementation you are using is, apparently, sticking to the Standard in that regard.

Try int main(void) which is mandated by the Standard to be correct (C11, 5.1.2.2.1).

pmg
  • 106,608
  • 13
  • 126
  • 198