I'm focusing now on this I/O thing, even writing a guide by looking some sources. I want to cover it all i can about stdin i/o and if it looks good in the end i'd love to share with you. But that's still OT.
I can't get rid of the line feed code char. x is a char, and when i write let's say "web" and hit enter, it prints out w, e, b and also a line feed.
I have tried with ((x = getchar()) && x != '\n') and also ((x = getchar()) && (int) x != 10).
What am i missing?
#include <stdio.h>
int main()
{
while(1)
{
char x = 0;
printf("\nInput: ");
while ((x = getchar()) && x != '\n'){
printf("\nchar x -> %c \nint x --> %i\n", x, x);
}
}
return 0;
}
Thank you