2008-04-24から1日間の記事一覧

45日目 getcharの基本に戻る

K&RのExcersise1-8やろうと思ったらgetchar()も忘れていた。 まずは単語カウント。 単純にカウントしたいならスペース+1じゃないかと考えた。 #include <stdio.h> main() { int c, ws; ws = 0; printf("Please type a sentence.\n\n"); while ((c = getchar()) != '</stdio.h>…