Вопрос по c++ – чтение из стандартного ввода в C ++

40

Error: User Rate Limit Exceeded

#include <iostream>
using namespace std;

int main() {
    while(cin) {
        getline(cin, input_line);
        cout << input_line << endl;
    };
    return 0;
}

Error: User Rate Limit Exceeded

[[email protected] krisdigitx]# g++ -o capture -O3 capture.cpp
capture.cpp: In function âint main()â:
capture.cpp:6: error: âinput_lineâ was not declared in this scope

Error: User Rate Limit Exceeded

Ваш Ответ

1   ответ
66

input_line.

string input_line;

#include <string>

getline

#include <iostream>
#include <string>

int main() {
    for (std::string line; std::getline(std::cin, line);) {
        std::cout << line << std::endl;
    }
    return 0;
}
Error: User Rate Limit Exceededfor (string s; getline(cin, s); ) { cout << s << endl; }Error: User Rate Limit Exceededreturn 0Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededreturn 0Error: User Rate Limit Exceeded

Похожие вопросы