cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
What does inputfile.str() mean?
What does inputfile.str() mean?
Aug 5, 2012 at 3:39am UTC
closed account (
Sh59216C
)
From my textbook, it asks the user to input the infile name
cin >> inputfile;
infile.open(inputfile.c_str());
Why does it add c_str() after the string variable inputfile??
Aug 5, 2012 at 3:44am UTC
Hippogriff
(727)
c_str() converts a string to a const char *. The reason it does this is because fstream is not able to work directly with string variable types (of course the value stays the same).
http://www.cplusplus.com/reference/string/string/c_str/
Topic archived. No new replies allowed.