On an old question I posted here earlier, I have asked about an issue I had on a FileOpen function. This new question regards the second part: a FileReader.
I made the changes, and still have compiler errors.
Here's the troublesome code:
FILE *FileReader(FILE *fname){
ifstream inputFile;
inputFile.open(fname);
if(inputFile){
string line = "";
//int num_chars;
while(getline(inputFile, line)){
//num_chars = strlen(text) + 1;
//line = (string *)malloc(sizeof(string)*num_chars)
int i = 0;
if(i <= 3 ){
storString[i] = line;
storage[i] = atoi(storString[i].c_str());
i++;
}
else{
string firstTwo = line.substr(0,1);
const int hex = atoi(firstTwo.c_str());
setOperations(hex);
string commandOne = firstTwo.substr(0,0); //first part of command
string commandTwo = firstTwo.substr(1,1); //second part of command and n-i flags
string restFlags = line.substr(2,2); //xbpe flags
rest = line.substr(3);
int disp = atoi(rest.c_str());
if(format == "fmt2"){
string rOne = line.substr(2,2);
int registerOne = atoi(rOne.c_str());
string rTwo = line.substr(3,3);
int registerTwo = atoi(rTwo.c_str());
registerOperation(hex, registerOne, registerTwo);
break;
}
setFlags(commandTwo, restFlags, disp);
}
}
}
}
The following errors are outputted:
a1/a1.cpp: In function FILE* FileReader(FILE*)
:
a1/a1.cpp:338: error: no matching function for call to std::basic_ifstream<char, std::char_traits<char> >::open(FILE*&)
/opt/local/bin/../lib/gcc/sparc-sun-solaris2.10/3.4.6/../../../../include/c++/3.4.6/fstream:570: note: candidates are: void std::basic_ifstream<_CharT, _Traits>::open(con
st char*, std::_Ios_Openmode)
[with _CharT = char, _Traits = std::char_traits]
Edit:
See those commented out lines. I also tried those, but have no idea how to implement them. Can anyone help me?