C++ Programming Ch.11 Exercise 4 Solution
Problem: ํ ์ค์ '์์ด๋ฌธ์ฅ;ํ๊ธ๋ฌธ์' ํ์์ผ๋ก ํค ์ ๋ ฅ๋ ๋, cin.ignore()๋ฅผ ์ด์ฉํ์ฌ ';'์ด์ ์ ์ ๋ ฅ๋ ๋ฌธ์์ด๋ง ์ถ๋ ฅํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ๋ผ. ์๋์์ ^Z(ctrl-z) ํค๋ ์ ๋ ฅ ์ข ๋ฃ๋ฅผ ๋ํ๋ด๋ ํค์ด๋ฉฐ, cin.get()์ EOF๋ฅผ ๋ฆฌํดํ๋ค. Execution Result: Objective & Hints: cin.get(), EOF, cin.ignore() ํ์ฉ Code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #include using namespace std; int main() { int ch; while( (ch = cin.get()) != EOF ) { if(ch == ';'){ cout.put('\n'); cin.ignore(100, '\n'); } else cout.put(ch); } } Explanation: ...