stringinput.cpp

来自「C++ sample code, for the book: C++ blac」· C++ 代码 · 共 27 行

CPP
27
字号
#include <iostream>
#include <string>
using namespace std;

int main()
{
    string string1;

    cout << "Type a few words: ";

    getline(cin, string1);

    cout << "You typed: " << string1 << endl;

    cout << "Type a word ";

    string1 = cin.get();
    cout << "The first character was " << string1;
    
    //while (cin.get() != '\n')
    //    continue;
    //cout << word << " is all I wanted.\n";

    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?