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은 문자열의 길이를 (즉 문자 배열의 길이)를 표현하면 된다.