
	                	                 
readline_on_new_line 함수는 std::cin.getline() 함수와 달리, Enter 키를 눌러도 새로운 줄이 출력되지 않고, 이전 줄에 계속 입력을 받습니다. 
readline_on_new_line 함수를 사용하면, 사용자 입력을 받을 때 Enter 키를 눌러도 새로운 줄이 출력되지 않아, 사용자에게 더 많은 입력 공간을 제공할 수 있습니다.
readline_on_new_line 함수를 사용하는 예시 코드는 다음과 같습니다.
#hostingforum.kr
cpp
#include 
#include 
int main() {
    std::string input;
    while (true) {
        std::cout << "Enter your input: ";
        std::getline(std::cin, input, 'n');
        if (input == "exit") {
            break;
        }
        std::cout << "You entered: " << input << std::endl;
    }
    return 0;
}
위 코드에서 std::getline(std::cin, input, '\n') 함수는 readline_on_new_line 함수와 유사하게 작동합니다. Enter 키를 눌러도 새로운 줄이 출력되지 않고, 이전 줄에 계속 입력을 받습니다.
readline_on_new_line 함수는 std::cin.getline() 함수와 달리, Enter 키를 눌러도 새로운 줄이 출력되지 않아, 사용자에게 더 많은 입력 공간을 제공할 수 있습니다.
readline_on_new_line 함수를 사용하는 예시 코드는 다음과 같습니다.
#hostingforum.kr
cpp
#include 
#include 
int main() {
    std::string input;
    while (true) {
        std::cout << "Enter your input: ";
        std::cin.getline(input, 1024);
        if (input == "exit") {
            break;
        }
        std::cout << "You entered: " << input << std::endl;
    }
    return 0;
}
위 코드에서 std::cin.getline(input, 1024) 함수는 readline_on_new_line 함수와 달리, Enter 키를 눌러도 새로운 줄이 출력됩니다.
따라서 readline_on_new_line 함수를 사용하면, 사용자에게 더 많은 입력 공간을 제공할 수 있습니다.
2025-04-08 11:13