why is this solution giving NZEC:
and this solution is giving SIGSEGV:

I think there is some problem in fread…if possible some1 xplain me why is dis wrong and correct the code

The first one is giving NZEC because you need to declare your main function to return int i.e. int main and also need to add a return 0; at the end of main.

I dont know exactly about second one but i would suggest that you remove all the fread and stdin and replace it with simple printf and scanf or cout and cin.

@priyanka1992 >> Because your program is not processing the input the way it should have.

Try with the sample input, for example


It doesn’t print anything. That is because you’re taking t as input and then you’re not using it anywhere, your while loop just carries on and on.

Well i have submitted many solutions with void main and it worked…so i dont think that the return type of main has to be int necessarily…yes ommting return 0 gives NZEC but only when you declare the return type of main as int…

Please refer to this FAQ : . NZEC is caused by not returning zero from main in C or due to some exeptions. main has to be of type int.

kchahdog: i’m getting the answer using printf nd scanf but that is my doubt why am i getting wrong answer with fread.