Related Posts Plugin for WordPress, Blogger... 簡單易懂的低調手札: [memo] C++ 矩陣 與 讀取一整行字串 cin.getline

2011年7月2日 星期六

[memo] C++ 矩陣 與 讀取一整行字串 cin.getline

#include <iostream>
//#include
using namespace std;

int main()
{

const int ArSize = 20;
char name[ArSize];
char dessert[ArSize];

cout << "Enter your name: \n";
cin.getline(name ,ArSize);
cout << "Enter your favorite dessert: \n";
cin.get(dessert,ArSize);
cout << "I have some delicious "<< dessert ;
cout << " for your, " << name << ".\n";







system("pause");
return 0;
}


沒有留言:

張貼留言