Network Talk tool help

This is a discussion on Network Talk tool help within the C++ Programming forums, part of the General Programming Boards category; The question is: What i need to know is how i can put a variable into a function..which is System(""); ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    1

    Network Talk tool help

    The question is:

    What i need to know is how i can put a variable into a function..which is System("");

    but for a more detailed question please read on below

    Hi im new to C++ but do know (html,asp,php,mysql,javascript) all the major internet ones so i have a coding background. My question is that im trying to make a basic program to later become more in depth but what it is to do is take a typed in message then send it to another computer but before even getting to this far i have stummbled. im using the command
    Code:
    System(" .... ");
    what i need inside the system command is
    Code:
    net send pcname string
    In case your lost already this is what i have already
    Code:
      
    #include <iostream.h>
    #include <stdlib.h>
    
    int main(void)
    { 
      char string[256];
      char string2[256];
      cout<<"Please enter your Message to pcname:";
      cin.getline(string, 256, '\n');
      cout <<"You entered: "<<string;
    
    
      cout <<"\n\n";
      system("net send pcname" <<string);
      system("Pause");
      return 0;
    }

    its getting the bit in the system part to work
    it should basically read

    Code:
    System("net send pcname HELLO WORLD");
    HELLO WORLD being whatever string is.

    After all that what i need to know is how i can put a variable into a function..which is System("");


    Sorry if ive confused anyone but any help will be MUCH appreciated

    Thanks
    Chris Ella
    Last edited by chrisella; 08-24-2004 at 01:26 PM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Look up the string related functions. Specificly strcpy. While you're at it, read up on the rest of the string functions also.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,702
    or something like:

    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    int main(void)
    { 
      string message, command = "net send pcname ";
      cout<<"Please enter your Message to pcname:";
      cin >> message;
      command += message;
      cout <<"You entered: "<<message<<"\n\n";
      system(command.c_str());
      system("Pause");
      return 0;
    }
    the system() function expects a single argument, a const char * - so you have to use the ::c_str() function to obtain that from a string object.
    Code:
    bool flip(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() < 0;
    }

  4. #4
    Registered User
    Join Date
    Aug 2004
    Posts
    6
    Here is a program I wrote to do this. Take a look.
    Code:
    #include <iostream>
    #include <sstream>
    #include <string.h>
    using namespace std;
    
    int main(void)
    {
    
        int nummsg;
        int n = 0;
        std::stringstream stream;
        char ipaddr[20];
        char msg[200];
    	
        cout << "MeGaBiTe1's Net Send App v0.1\n";
        cout << "Enter Computer Name or IP:\n ";
        cin >> ipaddr;
        cout << "Enter Message:\n ";
        cin.getline (msg,200);
        cin.getline (msg,200);
        cout << "Enter Number of Messages to be Sent:\n ";
        cin >> nummsg;
    	
        stream << "net send " << ipaddr << ' ' << msg; 
    
        system ("PAUSE");
    
        while (n < nummsg) {
            std::system(stream.str().c_str());
            n++;
        } 
        
        system ("PAUSE");
        
    return 1;
    }
    Let's you input how many messages to send also.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What one line unix talk combo generates the following....
    By Overworked_PhD in forum Tech Board
    Replies: 1
    Last Post: 01-20-2008, 07:48 AM
  2. 3D Network Analysis Tool
    By durban in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 11-08-2005, 05:33 PM
  3. Need help with easy Network setup
    By the dead tree in forum Tech Board
    Replies: 9
    Last Post: 04-08-2005, 07:44 PM
  4. network problems
    By lucy in forum Tech Board
    Replies: 6
    Last Post: 01-01-2003, 02:33 PM
  5. WinXP Network Connections pop-up
    By DavidP in forum Tech Board
    Replies: 1
    Last Post: 10-02-2002, 05:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21