hello every one,
my code is to read a file and inserting it to a list and type it to a nother file my problem is with files when opening it it already be opened but i reads no thing from the file and i don't know why?
i want to know the reason.
Thanks.
my code:#include"ordering.h"
It's not infile.txt located on disc C, but file named "C:\\infile.txt".
Next thing is, that getline function have construction like this: getline(char * string, size_of_stream, char a). So you should change it: getline(line, (for example) 50); where characters are extracted until 50-1 characters have been extracted or, if you character a is found (if it's not defined, character a='\n').
I don't understand your question, where is the problem in your piece of code? If you use the same std::ifstream object to open/read/close multiple files, you shouldn't forget to call std::ifstream::clear() to reset the EOF flag each time. Did you mean that? Btw. you can use the std::getline() function directly in the loop:
1 2 3 4
while (std::getline(in, line))
{
A.inorder_insertion(line);
}
@mtweeman There is also a std::getline()function, which is NOT the std::istream::getline()method. So the code is correct.