0

読んでくれてありがとう。私はプログラミング入門クラスの新人プログラマーで、C++ のトレーニングを 1 か月しか受けていません。私は多くのアプローチでこのコードを修正しようとしましたが、入力文字列の 1 つの単語しか出力しない理由がわかりません。

 #include <iostream>
#include <cstdlib>
#include <string>
using namespace std;

void printThetxt(string);
string inputText(string);
    int main() {
        string x;
        printThetxt(inputText(x));
        system("pause");
            return 0;
}
void printThetxt(string y) {
    cout << y << endl;
}
string inputText(string x) {
cout << "Type in your string: " << endl;
    cin >> x;
    return x;
}

このコードが入力文字列の一部しか出力しない理由を教えてください。ありがとうございました!!

4

1 に答える 1