I'm trying to add strings to the window while getline() is getting lines from the opened text file. Using ncurses and c++, I am doing the following:
string line; //String to hold content of file and be printed
ifstream file; //Input file stream
file.open(fileName) //Opens file fileName (provided by function param)
if(file.is_open()) { //Enters if able to open file
while(getline(file, line)) { //Runs until all lines in file are extracted via ifstream
addstr(line); //LINE THAT ISN'T WORKING
refresh();
}
file.close(); //Done with the file
}
So my question is... what am I supposed to do in ncurses if I want to output something that isn't a const data type? None of the output functions I see in the documentation accept anything but const input.
It should be noted that this program works perfectly fine if I am just outputting the content of the file to the console, so that removes the possibility of it being a file reading/opening error or something with the stream. The exact error I get on compilation is:
error: cannot convert ‘std::__cxx11::string {aka std::__cxx11::basic_string}’ to ‘const char*’ for argument ‘2’ to ‘int waddnstr(WINDOW*, const char*, int)’ addstr(line);
Let me know if you need any more info.
EDIT: Added links to relevant documentation.
Aucun commentaire:
Enregistrer un commentaire