counting program

언어/C 2016. 2. 18. 17:39

Counting Program


Source Code

#include <stdio.h>

int main() {

double nc;

for(nc=0;getchar()!=EOF;++nc)

;

printf("%.0f\n",nc);

}


if the input contains no characters, the while or for test fails on the very first call to get char, and the program produces zero. while and for is that they test at the top of the loop, before proceeding with the body. If there nothing to do, nothing is done. Even if that means never going through the loop body.


Source : The C Programming language

'언어 > C' 카테고리의 다른 글

구조체 기초 (union, struct의 차이)  (0) 2016.03.07
escape sequence  (0) 2016.02.26
Symbolic Constants  (0) 2016.02.16
구조체(structure) - 중급  (0) 2016.01.09
구조체(structure) - 기초  (0) 2016.01.08
Posted by 知彼知己百戰不殆
,