0
私は以下の問題を抱えています:C++端末の出力が新しい行を生成しない
私のC++コードはこのようになります。要するに
int main()
{
std::string String;
int rows = 0;
int cols = 0;
std::getline (std::cin,String);
std::cin >> rows;
std::cin >> cols;
std::cout << "Enter a fancy string: " << String << std::endl;
std::cout << "Enter the number of rows: " << rows << std::endl;
std::cout << "Enter the number of cols: " << cols << std::endl;
std::string ArrayofStrings;
for(int x = 0; x<rows; x++){
ArrayofStrings = "";
for (int y = 0; y < cols; y++) {
ArrayofStrings += String;
}
std::cout << ArrayofStrings << std::endl; }
// std::cout << std::endl;
return 0;
}
、それが文字列を読み込み、指定された寸法を有する指定された文字列の配列をプリントアウト。しかし、私は、Linuxのターミナル上でそれを実行すると、出力は次のようになります。
Enter a fancy string: 4
Enter the number of rows: 5
Enter the number of columns: 5
44444
44444
44444
44444
44444[[email protected]] (3)$
しかし、私は何があっラインからその[enkhtaiv王室-10 @] Linuxテキスト開始することはできません。私はstd::endl, "\n"
の両方を試しましたが、動作していないようです。
このプログラムはIDE上でうまく動作しますが、コンパイルしてLinux端末で実行するとこの問題は解決しません。 私はC++とLinuxの初心者ですから、これが完全に些細な質問であれば事前にお詫びします。