| | |
problem with system() function...
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
hello there, im having trouble with the system() function...as much as possible, i would like my program to be dynamic...i created a program that will make an iso file...it will ask the user to input the directory that he would like to compress...the problem is, how do i append this to the system() function...here is my code...
notice the + directory?? lol...it's obviously wrong...help pls...
c Syntax (Toggle Plain Text)
_________________________________________ #include <stdlib.h> #include <iostream> using namespace std; const char *directory; int main(){ cout << "enter directory name: "; cin >> directory; system("ls -l"); system("mkdir"+directory); system("mkisofs -J -o filename.iso "+directory); return 0; } ______________________________________________
Last edited by WaltP; May 10th, 2007 at 1:30 am. Reason: Added CODE tags -- you actually typed right over how to use them when you entered this post...
Retreat!!!
The easiest way is to make a C++ string and use its concatenation operator (which happens to be the plus operator). Use the c_str method to get the C-style string that's similar to the C++ string you've concatenated that the system function needs.
C++ Syntax (Toggle Plain Text)
#include <stdlib.h> #include <iostream> #include <string> using namespace std; int main(){ string directory; cout << "enter directory name: "; cin >> directory; system("ls -l"); system(("mkdir " + directory).c_str()); system(("mkisofs -J -o filename.iso " + directory).c_str()); return 0; }
All my posts may be redistributed under the GNU Free Documentation License.
![]() |
Similar Threads
- c++ system() function?? (C++)
- System function, output to file (C++)
- how to make utilize of system( ) function (C)
- Problem in displaying returned value from function (C#)
- System() Function: Info on uses & Description (C++)
Other Threads in the C++ Forum
- Previous Thread: Help with a program
- Next Thread: exam technique?
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node output parameter pointer problem program programming project proxy python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






