C++/ํจ์ (Function)
[C++] c type string์ ๋ํ getline ํจ์์ ํ์ฉ
Chan Lee
2024. 1. 16. 01:34
c++ type string์ ๋ํ getline ํจ์๋ ๋ค์๊ณผ ๊ฐ์ด ์ฌ์ฉํ๋ค.
std::string mystr;
std::getline(std::cin, mystr);
std::cout << mystr << std::endl;
C type string์ ๋ํ getline ํจ์๋ ๋ค์๊ณผ ๊ฐ์ด ์ฌ์ฉํ๋ค.
char str[100];
std::cin.getline(str, 100);
printf("%s", str);
(str, 100)์์ 100์ ๋ฌธ์์ด์ ๊ธธ์ด๋ฅผ (์ฆ ๋ฌธ์ ๋ฐฐ์ด์ ๊ธธ์ด)๋ฅผ ํํํ๋ฉด ๋๋ค.