1.5.2 Character Counting

作者在 2009-02-13 10:03:10 发布以下内容
/* 1st version */
#include<stdio.h>
 
int main(void)
{
    int c, nc;
 
    nc = 0;
    while((c = getchar()) !=EOF)
    {
        ++nc;
    }
   
    printf("%d",nc);
   
    getch();
    return 0;
}
======================
/* 2nd version */
#include <stdio.h>
 
int main(void)
{
    int c, nc;
 
    for (nc = 0; (c = getchar()) != EOF; ++nc)
        ;
    printf("%d",nc);
 
    getch();
    return 0;
}       
文章评论,共0条
游客请输入验证码
浏览27703次
文章归档