Thread: Help With system(); command

  1. #1
    Registered User
    Join Date
    Feb 2005

    Help With system(); command

    I have tryed different ways to solve this problem, but this is what I need help on.

    lets say my program has already asked for a hostname and message

    each are set with

    char hostname[50];
    char message[256];

    and each called and stored with the input with
    cin.getline ( hostname, 50, '\n' );
    and the same for message

    What I would now like to do is use the system(); command to run a NET SEND

    and in the command include
    (NET SEND hostname message) where hostname and message already have a value.

    how would I do this. I have tryed like system("NET SEND " hostname message); and different things like that but it just wont work. I hope you get what I mean, thanks ALot!

    EDIT: I am using Dev-C++
    Last edited by GUIPenguin; 02-03-2005 at 10:42 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Use strcpy and strcat to build up a string, then pass the completed result to system()
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Try this.
    #include <string>
    using namespace std;
    string hostname;
    string message;
    //and each called and stored with the input with
    getline ( cin, hostname );
    getline ( cin, message );
    string command = "NET SEND " + hostname + " " + message;

  4. #4
    Registered User
    Join Date
    Feb 2005
    Thanks Swoopy, works great!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. system command not executing with format specifier
    By ridhamshah in forum C Programming
    Replies: 6
    Last Post: 11-08-2006, 05:58 AM
  2. Help on System Command
    By Smoki in forum C++ Programming
    Replies: 5
    Last Post: 12-14-2005, 06:47 PM
  3. Problem using system() command.
    By mmongoose in forum C++ Programming
    Replies: 2
    Last Post: 08-20-2005, 08:44 PM
  4. System() command opens a dos-box
    By phil_drew in forum Windows Programming
    Replies: 2
    Last Post: 03-16-2004, 07:43 AM
  5. IDEA: Customizeable command system
    By Inquirer in forum Contests Board
    Replies: 1
    Last Post: 10-02-2002, 10:17 PM