This simple code is producing weird output.
I write a line and press enter, it echo's the line...well, supposed to...Because, sometimes, it is not showing.
In code blocks, i can assume that when the program is returning zero the program is terminating correctly.
I tried to figure out, when it shows something different then zero..i found that no matter what the program termination status is(zero or some other garbage number), the output is completely random...sometimes, it is showing, and sometimes it is not.
Can anyone tell me why?
#include<stdio.h>
int main()
{
char *array;
gets(array);
while(*array)
printf("%c", *array++);
return 0;
}
Later on, i tried to execute the problem in Visual C++...but, the program shows crashes after entering the line...so i concluded that the problem is with this :
gets(array);
But, why sometimes, the code is running in codeblocks if the code is wrong?(Codeblocks is using GCC)
I wanted to take a line input of infinite length.Can this be a way to implement the plan?