how do I put a variable in the end of this command.
system("command");
An example woud be: system ("ping") + IP;
yhx
how do I put a variable in the end of this command.
system("command");
An example woud be: system ("ping") + IP;
yhx
do conversions of one type or another until you get a single string of input. then use that in the system command.
you go like this:
THIS CODE IS UNTESTED, BUT IT IS SOMETHING ALONG THE LINES OF THATCode:char blah1[10]; int blah2[10]; char command[20]; blah1 = ping; blah2 = 127.0.0; strcat(command, blah1); strcat(command, blah2); system(command);
"There are three kinds of people in the world...
Those that can count and those that can't."
Use sprintf.
char szBuffer [100] ;
int IP = 127.0.0.1;
sprintf(szBuffer, "ping %d", IP) ;
system(szBuffer);
Remember to include stdio.h
This is similar to OkieSmokies example:
try this:
char *ipaddr = new char[11];
char *ping = "ping ";
cin.getline(ipaddr, 10, '\n');
strcat(ping, ipaddr);
system(ping);
tudehopet uses Borland Compiler 5.5
and Visual C++ 6.