By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,806 Members | 1,457 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,806 IT Pros & Developers. It's quick & easy.

system variables?

P: n/a
How do i get a string variable to be included into a system command?
For example:

#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
string reply;
cout << "What do you want to say? ";
cin >> reply;
system("net send 192.168.***.*** "); //how do i get the string
variable, "reply" after the IP?
system("PAUSE");

return 0;
}

any help would be appreciated thx

Apr 24 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ch**********@gmail.com wrote:
How do i get a string variable to be included into a system command?
For example:

#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
string reply;
cout << "What do you want to say? ";
cin >> reply;
system("net send 192.168.***.*** "); //how do i get the string
variable, "reply" after the IP?
system("PAUSE");

return 0;
}


This is usually accomplished by having a _variable_ of type 'std::string'
and forming it from different parts during run-time, and then passing it
to 'system' function:

string command("net send blah ");
system((command + reply).c_str());

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Apr 24 '06 #2

P: n/a
thx alot!!!

Apr 24 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.