Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. main(){
  2. long cnt; // chars count
  3. int c;
  4.  
  5. /* Why the 'for' cicle doesn't finish when I input the
  6. * "a^Z" string and press ENTER? At this case '^Z' is
  7. * CTRL + Z (i.e this is EOF). I expected the second loop
  8. * will get the EOF (i.e. -1), but it has 26 instead of. Why?
  9. */
  10. for(cnt = 0; (c = getchar()) != EOF; ++cnt)
  11. ;
  12.  
  13. printf("Chars count: %ld", cnt);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement