system variables?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cheesywillie@gmail.com

    system variables?

    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

  • Victor Bazarov

    #2
    Re: system variables?

    cheesywillie@gm ail.com wrote:[color=blue]
    > 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;
    > }[/color]

    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


    Comment

    • cheesywillie@gmail.com

      #3
      Re: system variables?

      thx alot!!!

      Comment

      Working...