C
csvka
Hello,
I wonder if I could pick your brains. I'm beginning to learn about C++. I
have opened a file in my program and I want to read lines from it. I would
like this to be done in a separate function called readline() because I
would also like to do some processing on the line each time (ignoring
comments and so on).
I have:
void Fileloader::readline(char *string, ifstream file) {
file.getline(string, sizeof(string), '\n');
}
And in another function I have:
ifstream file;
file.open("myfile.txt", ios::in);
char string[512];
readline(string, file);
To call my readline file.
This comes up with lots of errors like:
/usr/include/c++/3.3.1/bits/ios_base.h:668: error:
`std::ios_base::ios_base(const std::ios_base&)' is private
fileloader.cpp:62: error: within this context
Can anyone see what I'm doing wrong and point me in the right direction?
Thanks very much,
Tom
I wonder if I could pick your brains. I'm beginning to learn about C++. I
have opened a file in my program and I want to read lines from it. I would
like this to be done in a separate function called readline() because I
would also like to do some processing on the line each time (ignoring
comments and so on).
I have:
void Fileloader::readline(char *string, ifstream file) {
file.getline(string, sizeof(string), '\n');
}
And in another function I have:
ifstream file;
file.open("myfile.txt", ios::in);
char string[512];
readline(string, file);
To call my readline file.
This comes up with lots of errors like:
/usr/include/c++/3.3.1/bits/ios_base.h:668: error:
`std::ios_base::ios_base(const std::ios_base&)' is private
fileloader.cpp:62: error: within this context
Can anyone see what I'm doing wrong and point me in the right direction?
Thanks very much,
Tom