I'm having a problem. I'm trying to use getline to capture a data in a string object from the user. The problem is that getline doesn't seem to be recognized by Borland C++ for string data capture.
It is defined for char * handling, but I see don't see where it supports the string class data type.
Here is a sample snippet:
Code:
#include <iostream.h>
#include <string>
void main()
{
string sName;
char cName[50];
cin.getline(cName, 50, '\n'); // this works
getline(cin, sName); // this doesn't
}
When I try to use the second getline call, the compiler gives me the following error:
Call to undefined function 'getline'
I am using Borland C++ 5.02 - which has a lotta stuff defined radically differently than how I see it everywhere else - especially in this forum. For example, it is iostream.h that contains the getline function, not string.h.
Also, apparently cin and cout are not members of the std class. But that's just the tip of the iceberg.
Also, the following variations don't work either:
Code:
cin.getline(sName, 50, '\n');
getline(std::cin, sName);
//as suggested by Prelude in a previous response to another post
I gladly welcome your insights into this rather peculiar issue. Thanks.