I've tried using both of those and neither of them work. I've included the string header file and everything. I'm thoroughly confused.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
void Prog1Class::setStructData()
{
for(int i=0; i<5; i++)
{
cout << "Please enter an integer value: " << endl;
cin >> privArray[i].m_iVal;
for(int j=0; j<5; j++)
{
cout << "Please enter a double value: " << endl;
cin >> privArray[i].m_dArray[j];
}
cout << "Please enter a multi-word string: " << endl;
cin.getline(privArray[i].m_sLine, 79);
}
|
And I did it the other way replacing the "cin.getline" line with this:
|
getline (cin, privArray[i].m_sLine);
|
Neither will work. For cin.getline it crashes at that point, for getline(cin, blahblah) it doesn't compile and gives me these error messages:
"error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_string<_Elem,_Traits,_Alloc> &' from 'char [80]'"
and
"error C2780: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : expects 3 arguments - 2 provided"
Any idea?