ive decided to learn c, as a base to learn object c cocoa and java, so i got a copy of K&R and was fine for few pages, wrote a few short things from imagination which worked and i was happy, but then the next example fails to compile, so its not me cause its the example and i just get an error when compiling it.
im using xcode, so there is a chance i could have set that up wrong, but i didnt get any errors till this example.
the example is
Code:
#include <stdio.h>
#define IN 1 /* inside a word */
#define OUT 0 /* outside a word */
/* count lines, words, and characters in input */
main()
{
int c, nl, nw, nc, state;
state = OUT;
nl = nw = nc = 0;
while ((c = getchar()) != EOF) {
++nc;
if (c == '\n')
++nl;
if (c == ' ' || c == '\n' || c = '\t')
state = OUT;
else if (state == OUT) {
state = IN;
++nw;
}
}
printf("%d %d %d\n", nl, nw, nc);
}
and the error is shown by xcode as being "if (c == ' ' || c == '\n' || c = '\t') " in that but it could be the line above.
but either way im stuck cause its the first example in the section so i dont understand the subject enough to even have a clue what im doing wrong.
sorry it such a simple question but i cant find anyone with the same problem on the net.
thanks