![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2005
Posts: 10
Rep Power: 0
![]() |
system(const char*)
this function in c++ works as follows -> system("c:\example.exe");
but i wish to pass a string instead of writing it -> system(myString); where myString has paths that can be changed on running time. how do i declare the string or what can i do to use a standar (std::string myString="hello") one in 'system' function? |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
It has to be a character array (or converted to one)...
#include <iostream>
int main(int argc, char *argv[]) {
char sys[1024] = "C:\\Program Files\\Internet Explorer\\iexplore.exe ";
char input[256];
std::cout << "What website would you like to view? ";
std::cin >> input;
strcat(sys, input);
system(sys);
return 0;
}
__________________
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Feb 2005
Posts: 10
Rep Power: 0
![]() |
thanks
thanks!!!
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|