I read the C ++ Primer book and in the chapter on inputting the output of the file it uses:
ifstream infile(ifile.c_str());
to open the file whose name is in the ifile line.
I tried the code and it works fine even without c_str() . So what is its meaning?
Should I use c_str() when I try to open a file from a command line argument? I mean this is the correct use:
ifstream fin( argv[1] )
or
ifstream fin( argv[1].c_str() )
zsero
source share