循环从键盘输入

来源:互联网 发布:移动办公软件有哪些 编辑:程序博客网 时间:2024/05/16 08:52

循环从键盘输入

  1. cin.getline()行输入
  2. 已不同字符结束,或者截断
// xigouhanshu.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <vector>#include <string>using namespace std;int main(){        const size_t NUM = 100;    char otherthing[NUM]; //此处要求是char 数组,不能是string    /*cin >> anything;    cout << anything;*/    while(cin.getline(otherthing, 100, '\n'))    cout << otherthing << endl;//while(cin.getline(otherthing, 100, '\0'))//while(cin.getline(otherthing, 100, '\t'))//while(cin.getline(otherthing, 100, '0'))    system("pause");    return 0;}
原创粉丝点击