system()

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?
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() ) 

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.