字符串输入输出cin.get的用法

来源:互联网 发布:刘亦婷混的好吗知乎 编辑:程序博客网 时间:2024/05/01 02:10
#include "stdafx.h"#include "iostream"#include "windows.h"#include "string"#include "cstring"using namespace std;int main(int argc, char* argv[]){char name[21],ch[21];int age;cout<<"Please enter your name : \n";cin.get(name,20).get();cout<<"Please enter your mother's name : \n";cin.get(ch,20);cout<<"Please enter your age : \n";cin>>age;cout<<"Your name is "<<name<<" Your mother's name is "<<ch<<" your age is "<<age<<endl;system("pause");return 0;}

原创粉丝点击