Hi everybody,
I'm writing a program which use the <string>, <vector> and <ifstream>
classes.
Given an array of string, i.e vector<string> file_names, example :
file_names[0] = "file1.txt"
file_names[1] = "file2.txt"
etc ...
I want to do a for-loop and read the content of all of this files, I
started with (n_file is the size of the dynamical allocated array
file_names) :
for (in_file = 0; in_file < n_file; ++in_file)
{
ifstream file(file_names[in_file],ios::in);
// here the data handling of the content of the file
file.close();
}
It doesn't work, I get a message error during the compiling process
(gnu gcc comiler on linux) :
opt_main.c++:26 1: error: no matching function for call to `
std::basic_ifst ream<char, std::char_trait s<char> >::basic_ifstre am(
std::string&, const std::_Ios_Openm ode&)'
/usr/local/bin/gcc3_3/include/c++/3.3/iosfwd:89: error: candidates
are:
std::basic_ifst ream<char, std::char_trait s<char>[color=blue]
>::basic_ifstre am(const[/color]
std::basic_ifst ream<char, std::char_trait s<char> >&)
/usr/local/bin/gcc3_3/include/c++/3.3/fstream:519: error:
std::basic_ifst ream<_CharT, _Traits>::basic _ifstream(const char*,
std::_Ios_Openm ode = std::ios_base:: in) [with _CharT = char,
_Traits =
std::char_trait s<char>]
/usr/local/bin/gcc3_3/include/c++/3.3/fstream:504: error:
std::basic_ifst ream<_CharT, _Traits>::basic _ifstream() [with _CharT
= char,
_Traits = std::char_trait s<char>]
It's (I guess) probably due to the use of a string or the absence of
quotes in :
ifstream file(file_names[in_file],ios::in);
I've tested instead ifstream
file("\""+file_ names[in_file]+"\"",ios::i n), the quotes are then
present in the string but It still doesn't work.
I've checked that ifstream file("file1.txt ",ios::in) is OK for (one
after the others) all the files.
If soeone has got an idea ...
Thanks in advance
Herve
I'm writing a program which use the <string>, <vector> and <ifstream>
classes.
Given an array of string, i.e vector<string> file_names, example :
file_names[0] = "file1.txt"
file_names[1] = "file2.txt"
etc ...
I want to do a for-loop and read the content of all of this files, I
started with (n_file is the size of the dynamical allocated array
file_names) :
for (in_file = 0; in_file < n_file; ++in_file)
{
ifstream file(file_names[in_file],ios::in);
// here the data handling of the content of the file
file.close();
}
It doesn't work, I get a message error during the compiling process
(gnu gcc comiler on linux) :
opt_main.c++:26 1: error: no matching function for call to `
std::basic_ifst ream<char, std::char_trait s<char> >::basic_ifstre am(
std::string&, const std::_Ios_Openm ode&)'
/usr/local/bin/gcc3_3/include/c++/3.3/iosfwd:89: error: candidates
are:
std::basic_ifst ream<char, std::char_trait s<char>[color=blue]
>::basic_ifstre am(const[/color]
std::basic_ifst ream<char, std::char_trait s<char> >&)
/usr/local/bin/gcc3_3/include/c++/3.3/fstream:519: error:
std::basic_ifst ream<_CharT, _Traits>::basic _ifstream(const char*,
std::_Ios_Openm ode = std::ios_base:: in) [with _CharT = char,
_Traits =
std::char_trait s<char>]
/usr/local/bin/gcc3_3/include/c++/3.3/fstream:504: error:
std::basic_ifst ream<_CharT, _Traits>::basic _ifstream() [with _CharT
= char,
_Traits = std::char_trait s<char>]
It's (I guess) probably due to the use of a string or the absence of
quotes in :
ifstream file(file_names[in_file],ios::in);
I've tested instead ifstream
file("\""+file_ names[in_file]+"\"",ios::i n), the quotes are then
present in the string but It still doesn't work.
I've checked that ifstream file("file1.txt ",ios::in) is OK for (one
after the others) all the files.
If soeone has got an idea ...
Thanks in advance
Herve
Comment