小编Bre*_*ent的帖子

我对getline +字符串的理解是什么?

这是我第一次使用stackoverflow.我一直无法找到关于getline的所需信息.我是一个简单的工程转移编程类,所以我们编写的代码非常简单.我在这里尝试做的就是将用户定义的问题和答案放入两个不同的数组中.我的while循环看起来像这样(我正在使用for循环,但切换到只是为了看它是否会停止破坏):

int main ()
{
    srand((unsigned)time(0));
    string quest1[100], answ1[100];
    int size1, x = 0, num, count1, visit[100], shuffle[100];
    fstream flashcard1; 

    cout << "flashcard.cpp by NAME\n" << endl;
    cout << "This program allows user to manipulate questions and answers for studying.\n" << endl;
    cout << "\nHow many flash cards will be entered(MAX 100)? ";
    cin >> size1;
    cout << endl;

    while(x < size1)
    {
        cout << "Enter Question: ";
        getline(cin , quest1[x]);
        cout << endl;
        x = x++;

        /*
        cout << …
Run Code Online (Sandbox Code Playgroud)

c++ arrays string getline

11
推荐指数
1
解决办法
771
查看次数

标签 统计

arrays ×1

c++ ×1

getline ×1

string ×1