Alright, be gentle, since I\'m very much a novice to programming. So far I\'ve only studied C++ and I\'m running Visual Studio 2010 as my compiler. For this program, I\'m trying
fstream
's getline
function has these signatures.
std::istream& getline (char* s, streamsize n );
std::istream& getline (char* s, streamsize n, char delim );
In your code...
string nameAr[EMP_NUM];
// stuff...
inFile.getline(nameAr[i], EMP_NUM, "*");
You are trying to use a std::string
where getline
wants a char*
- you cannot convert from string
to a char*
like this.
One approach is you can use a character buffer to store the contents of getline
, like this.
const int BUFFER_SIZE = 1024;
char buffer[BUFFER_SIZE];
inFile.getline(buffer, BUFFER_SIZE, '*');
// more stuff...
A better solution
I'd recommend using std::getline
from
, as you can use string
types instead of C-strings.
#include
// stuff...
std::getline(inFile, nameAr[i], '*');
edit Links for you since you are learning