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
system()
system()
Jan 16, 2008 at 7:01pm UTC
jherrico
(2)
im having problems passing arguments to system()
what im doing is creating a string and using getline to populate that string from a text file (when i use cout << to show the contents of that string to the console it works fine) then im trying to use system() to open a program () like this
system("c:\\somePathHere\" + string + "\somePathHere")
i would think this would create
system("c:\\somePathHere\stringData\somePathHere")
but all i get is an error:
cannot convert 'std::string' to 'const char*' for argument '1' to 'int system(const char*)'
any thoughts?
Jan 17, 2008 at 12:21pm UTC
martinlb
(38)
that function seems to accept only a "const char*" argument, not strings.
An option would be to use c_str member, something like:
system( string(
"c:\\somePathHere\" + string + "
\somePathHere
").c_str() )
Jan 18, 2008 at 6:16pm UTC
jherrico
(2)
that worked perfectly.
i did some messing around with c-style strings before i posted here but i couldent get it to work right. im still pretty new to c++
thanks a bunch
Topic archived. No new replies allowed.