#include<iostream>
using namespace std;
int main()
{
int spaces = 0;
int total = 0;
char ch;
cin.get(ch);
while (ch != '.')
{
if (ch == '\0')
++spaces;
++total;
cin.get(ch);
}
cout << spaces << "spaces" << total;
cout<< " characters total in sentence\n";
return 0;
}
在DOS視窗輸入字串之后 按回車就退出視窗了 沒有看到回圈被執行和后面的cout陳述句
uj5u.com熱心網友回復:
因為你的字符型的ch沒有賦初始值uj5u.com熱心網友回復:
程式運行完自然就退出了return 0; 前面加上getchar();
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/124232.html
標籤:一般軟件使用
