getline() from string array not working

1
2
getline(cin, reminders[0]);
cin.clear();


The getline command doesn't seem to work if I'm trying to type a message into a string array, am I doing something wrong?, or can c++ just not do this?. I've checked, and if I remove all code but this, it still doesn't work, so I either forgot something of this doesn't work. Help would be appreciated.
Last edited on
Can you post your whole code
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <string>
using namespace std;

int main(){
    string reminders[2];
    getline(cin, reminders[0]);
    cout << reminders[0];
    cin.get();
    return 0;
}
How is you code different? (I removed cin.clear() because it served no purpose there. It is not the causo of your problems.)
EDIT: Never mind, I got it to work by replacing cin.clear with cin.get. //

PROBLEM SOLVED//
Last edited on
Topic archived. No new replies allowed.