halo all,
i've just started with K&R and got confused in this code.
i dont understand how this program runs.for eg. if i give as input the string "i am new to c"(without double quotes) and then press enter the output it gives is "i am new to c" but what i think the output should be "i" because in my opinion the code first looks for an input ,then checks it against EOF and if the character is not EOF then it should print the first character and again repeats the process.Code:#include<stdio.h> #include<conio.h> int main(void) { clrscr(); int c; c=getchar(); while(c!=EOF) { putchar(c); c=getchar(); } getch(); return 0; }
also if i run this code and give the same input(i am new to c) the output is what i expect i.e "i".
Code:c=getchar(); putchar(c);