Is it possible to output a variable as a cmd command from a c++ program -


im making simple command line program c++ knowledge basic level, send command c++ program cmd made of part of command , rest variable here code far:

#include <iostream> #include <stdlib.h>  using namespace std;  int main() {     string directory;     cout<<"input directory make folder in: ";     cin>> directory;     system("mkdir" directory); } 

i error:

error: expected ')' before 'directory'| 

does know way of doing this? in end cmd execute command "mkdir c:*inputted directory*

i have hacked around trying work out, no success, have had on internet no avail, in advance.

rather call out shell use _mkdir (for windows) or mkdir (for linux) function instead:

_mkdir(directory.c_str()); 

for windows you'll need #include <direct.h>, linux you'll need #include <sys/stat.h> , #include <sys/types.h>


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -