I'm trying to read a file a line at a time and store it in a string using the getline() function. This is the troubled section:
The getline code makes the compiler have a debug assertion error in file fopen.c at line 53. It says the expression is 'file != NULL'. I can't even find fopen.c, it doesnt exist as far as i can tell. It must be generated or extracted at compile time. Why isn't my getline function working? Btw, here are the includes:
Code:
int cls_console::execScriptFile(const char* fileName){
int r;
string lin;
string strmsg;
string strfil;
ifstream scr(fileName);
strmsg = "cls_console.execScriptFile::Executing script file ";
strfil = fileName;
strmsg = strmsg + strfil;
logMessage(strmsg.c_str());
if (scr){
while(!scr.eof()){
getline(scr, lin);
r = doCommand(lin.c_str());
if (r) logMessage(getErrorString(r));
}
}else{
return 2;
}
logMessage("cls_console.execScriptFile::Finished");
return 0;
}
The getline code makes the compiler have a debug assertion error in file fopen.c at line 53. It says the expression is 'file != NULL'. I can't even find fopen.c, it doesnt exist as far as i can tell. It must be generated or extracted at compile time. Why isn't my getline function working? Btw, here are the includes:
Code:
#include <string>
#include <stdlib.h>
#include <fstream>
using namespace std;