Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Member List
Calendar
Today's Posts
Home
Forum
Topic
C
String object to system()
String object to system()
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
sudif
New Member
Join Date:
Apr 2007
Posts:
1
#1
String object to system()
Apr 1 '07, 10:53 AM
i want to make a c++ program that do something like this
string str;
cin >> str;
str="cat " + str;
int rv=system(str);
is there a way to do it?
JosAH
Recognized Expert
MVP
Join Date:
Mar 2007
Posts:
11453
#2
Apr 1 '07, 10:57 AM
Sure that's possible. Note that the system() function takes a char* instead of
a string; you have to convert your string, that's all.
kind regards,
Jos
Comment
Post
Cancel
Ganon11
Recognized Expert
Specialist
Join Date:
Oct 2006
Posts:
3651
#3
Apr 1 '07, 12:36 PM
In order to make the system call happy, just write
Code:
system(str.c_str());
instead of
Code:
system(str);
Comment
Post
Cancel
Previous
template
Next
Working...
OK
OK
Cancel
👍
👎
☕
Comment