I am trying to catch all characters that I input via my stdin
stream except EOF. I want to input a multi-line text: each line with \n
at the end.
int getline(char s[])
{
printf("Call-getline()\n");
int c;
int idx=0;
while((c=getchar()) != EOF)
{
s[idx++] = c;
}
printf("\n-EOF found--\n");
s[idx] = '\0';
return idx;
}
I don't know how to get rid of the \n
that I get when i press enter, and I was wondering if shif+enter
vs enter alone
makes any difference. I read about what it does in Microsoft Word: new paragraph vs newline.