Avatar of jchristn123
jchristn123

asked on 

Sending a string into system() command fails

Does anyone know how to pass string data to the system() call?

For instance:

string CommandLine = "ls -la";
system(CommandLine);

seems to fail when compiling with:

mix.c:52: error: cannot convert 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >' to 'const char*' for argument '1' to 'int system(const char*)'

Any thoughts?  Thanks!
C++

Avatar of undefined
Last Comment
Infinity08
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
C++
C++

C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.

58K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo