Hey i am trying to print each word on a new line. My EOF is also not working and was wondering why this is. i have made it to scan for a space and then print new line.
#include <stdio.h>
#include <ctype.h>
int main(void)
{
char ch;
while ((ch = getchar()) != '#')
putchar(ch);
int nextChar;
nextChar = getchar();
while (nextChar != '\n' && nextChar != EOF);
{
if (ch== ' ')
{
printf("\n");
}
else
{
putchar(ch);
}
{
ch = getchar();
}
printf("\n");
{
scanf("%lc",&nextChar);
printf("%c",nextChar);
}
return 0;
}
}
just for example input: Stackoverflow is great
output:
Stackoverflow
is
great