C++ Programming Ch.11 Exercise 5 Solution
Problem: λ€μ νλ‘κ·Έλ¨μ μμ 11-3μ μ½λμ΄λ€. μλ μ½λμμ char [] λμ stringμ μ΄μ©νμ¬ λ¬Έμμ΄μ λ€λ£¨λλ‘ νλ‘κ·Έλ¨μ μ¬μμ±νλΌ. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #include #include using namespace std; int main() { char cmd[80]; cout << "cin.get(char*, int)λ‘ λ¬Έμμ΄μ μ½μ΅λλ€." << endl; while(true) { cout << "μ’ λ£νλ €λ©΄ exitλ₯Ό μ λ ₯νμΈμ >> "; cin.get(cmd, 80); // 79κ°κΉμ§μ λ¬Έμ μ½μ if(strcmp(cmd, "exit") == 0 ) { cout << "νλ‘κ·Έλ¨μ μ’ λ£ν©λλ€...."; return 0; } else cin.ignore(1); // λ²νΌμ λ¨μ μλ ν€ ('\n') μ κ±° } } Execution Result: ...