<div>문제는 test.txt 파일에 P(p)나 A(a)가 들어간 단어의 개수를 찾는 프로그램을 만드는 것입니다</div> <div>단어의 정의는 띄우쓰니나 개행이 이루어 졌을때입니다.</div> <div>그래서 이렇게 짜보았는데 ㅠㅠ 계속 빈화면만 뜨네요....ㅠㅠㅠ </div> <div> </div> <div>#include <stdio.h></div> <div>int main()<br>{<br> FILE * rf=fopen("test.txt", "rt");</div> <div> char ch='0';<br> int ta=0, tp=0;</div> <div> while(ch!=EOF)<br> {<br> ch=fgetc(rf);<br> printf("%c ",ch);<br> if(ch=='A'||ch=='a')<br> {<br> ta+=1;<br> }<br> else if(ch=='p'||ch=='P')<br> {<br> tp+=1;<br> }<br> while(ch!=' '||ch!='\n')<br> {<br> ch=fgetc(rf);<br> }<br> }<br> printf("A로 시작하는 단어의 수: %d\n",ta);<br> printf("P로 시작하는 단어의 수: %d\n",tp);<br>}</div> <div> </div> <div>/*test.txt내용*/</div> <div>Apple banana Play<br>work plane<br>change lie lay low<br>vow</div>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.