4.3 instr1.cpp
#include <iostream>
int main()
{
using namespace std;
const int ArSize = 20;
char name[ArSize];
char dessert[ArSize];
cout << "Enter your name:\n";
cin >> name;
cout << "Enter your favorite dessert:\n";
cin >> dessert;
cout << "I have some delicious " << dessert;
cout << " for you, " << name << ".\n";
// cin.get();
return 0;
}
- 该程序作用就是读取来自键盘的输入,储存到数组中,之后再加以显示
- cin使用空白(空格、制表符、换行符)来确定字符串结束的位置,如果输入里需要有空格则该如何呢?请看下一程序
- 如果输入的字符串比设定数组的长度要长的话,则需要进一步探讨

4.4 instr2.cpp
#include <iostream>
int main()
{
using namespac