Lets say I have the below C code:
int getLine (char line[])
{
int c, i=0;
while( (c=getchar()) != EOF )
line[i++]=c;
line[i++] = c;
return i;
}
>> Enter: 007
>> ^Z
>> Output:
If we closely observe the way I give output above, I am pressing Enter
before stimulating EOF. This means, the length of string is 4 not 3 (excluding EOF).
When I am doing my exercises, I am really facing some trouble with that extra \n.
How do I stimulate EOF without newline? Is it possible at all?
>> Enter: 007^Z
>> ^Z
>> Output: length=6