Thank you for reading my thread,I am new to C and I have a big problem -Naturally.I cant seem to compile thise code:

# define EOF =-1
   int c,nl; // integers 
   nl = 0;  // assignment int ln to 0 value

        while ((c = getchar() !=EOF) // problem area :-(
                if (c =='\n') // here I believe the '\n' char means new line

The purpose of the code is to count the number of keys pressed :rolleyes:
but regardless of that, my problem start when I compile the code - it outputs error with 'while' line7 after = but other times :sad: error after ; which I obviously do not have:confused:

I am running on linux and my compiler is some strange application I read about in some dump e-book I downloaded some where(can't remember URL :sad: ) a few years ago called cc.

11 Years
Discussion Span
Last Post by Salem

the problem is

#define EOF =-1
while ((c = getchar() !=EOF) // problem area :-(

replace it with

#define EOF -1
while ((c = getchar()) != EOF) // problem area :-(

Thank you very much andor ;) I remember it now, 'cause I read about it in my dump e-book - just a few pages into the chapter.Thank you again for helping me out :o

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.