c programming language 케니건꺼

글자수 세려는데 몇줄짜서 해봤는데 안댐ㅋ

그래서 인터넷 answer 갖다붙여도 안댐 시발 ㅋ

int main(void) { int blanks, tabs, newlines; int c; int done = 0; int lastchar = 0; blanks = 0; tabs = 0; newlines = 0; while(done == 0) { c = getchar(); if(c == ' ') ++blanks; if(c == '\\t') ++tabs; if(c == '\\n') ++newlines; if(c == EOF) { if(lastchar != '\\n') { ++newlines; /* this is a bit of a semantic stretch, but it copes * with implementations where a text file might not * end with a newline. Thanks to Jim Stad for pointing * this out. */ } done = 1; } lastchar = c; } printf("Blanks: %dnTabs: %dnLines: %dn", blanks, tabs, newlines); return 0; }
왜 탭만 세지냐고 / 띄어쓰기하고 개행이 안세어져ㅠㅜㅜ