This actually bugging me from quite sometime now.The question is like this : How to set the the exit status of a program to any value without explicitly using return/exit in gcc/g++ ? Let us consider this piece of code : (Takes input from stdin and print it to the stdout until a zero input 0 is encountered)
#include <stdio.h>
int main() {
int n;
while(scanf("%d",&n) && n>0 )
printf("%d\n",n);
}
In my system (which is windows + mingw) it is returning 1,How to make it to return 0 or anything else implicitly without explicitly using exit/return ?
EDIT :
I modified the code a bit :
int f(int n) {
return (n>0);
}
int main(){
int n;
while(scanf("%d",&n)&&f(n))
printf("%d\n",n);
}
It's now returning 0 implicitly,but I couldn't draw any firm conclusion from this.