Here is the code
That's an example from K&R, but I can't understand how it can work.Code:#include <stdio.h> main () { int c, lastc; while ((c = getchar()) != EOF) { if (c != ' ') putchar(c); if (c == ' ') if (lastc != ' ') putchar(c); lastc = c; } }
The line with lastc is incomprehensible to me.
How can it check if lastc (which is actually nothing) is different from space?
Thanks in advance !



1Likes
LinkBack URL
About LinkBacks



