Learning C (via K&R) using xcode -


I am learning C with the C programming language (K & R).

Since I do not want to move forward and back between the text editor and the running GCC, I have decided to use the encoded as an idad. Up to now, I have been able to follow the example of the book without any problem till Section 1.5.2.

When a valid (?) Program was given ...

  #include & lt; Stdio.h & gt; Zero main () {long nc; NC = 0; While (getchar ()! = EOF) ++ NC; Printf ("% ld \ n", nc); }  

... I am not telling any final output how many characters were in my input. I am entering my input through the Xcode Console window.

On some debugging, it seems that my program gets trapped in the loop, and never encounters the EOF Token. To accommodate this, I replaced a new line as a new condition by changing "\ n" with EOF instead, whatever Does not and gives me an indication of indicator comparison warning.

What am I doing wrong here?

Do I use xcode & amp; Will R be able to follow?

(Control-d).

If you want to break a new line, you need to compare the return value of getchar to '\ n' , no That "\ n" . The previous one is the actual four value of a new line; If the latter is an indicator for a character with that value, if you do not understand it yet, do not worry, you will read more once.


Comments

Popular posts from this blog

php - multilevel menu with multilevel array -

c# - TypeConverter in propertygrid only converts from string, not to -

jQuery UI: Datepicker month format -