Re: [Dev-C++] quick question about sending stuff to windows
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Jason H. <jas...@bt...> - 2002-01-09 07:12:48
|
I don't know much about sending stuff around a lan, although if you can take
advantage of a system command then that would make things easier for you. If
you need to add your variables as a string to the net send command (I assume
there is a command like that available?) then you need to concatenate them
onto the net send command string. I suggest you use C++ strings for getting
the input and putting it all together and then convert it to a C string for
use in the command.
i.e.
#include <string>
#include <cstdlib>
#include <iostream>
int main()
{
std::string name, command;
char text[256];
command = "net send "; // assuming this is a valid command?
cout << "User name: ";
cin >> name; // Get's until whitespace
cout << "Send string: ";
cin.getline(text, 256); // Get's a line of text including whitespace
command += name + " " + text; // I'm unsure but this should work.
system(command.c_str()); // use the C string version of command
cout << "String sent." << endl; // a better way than "\n"
// do you need to pause?
}
This is all guess work, I don't know what is a valid way of sending messages
across your lan, but I hope it helps.
Jason.
----- Original Message -----
From: "Leonard Mazzone" <Leo...@Mi...>
To: <dev...@li...>
Sent: Wednesday, January 09, 2002 1:16 AM
Subject: [Dev-C++] quick question about sending stuff to windows
> im tring to make a quicky chat program for me and my friends to use over
> the school network. what i have so far looks like this :
>
> //net send simplyfier, good for lan chat
>
>
> #include <iostream.h>
> #include <stdlib.h>
>
> int main()
> {
> char name [20] ; //define variables
> char text [100] ;
> cout << ("what user to you want to messsage?" "\n")
> ;
> cin >> name ;
> cout << name ; //verbose
> cout << ("\n") ; //ending line
> cout << ("what is the text of the message you wish to
> send?" "\n");
> cin >> "text" ;
> cout << "text" ; //verbose
> cout << ("\n"); //ending line, is there a
> better way?
> system("net send name text"); // uses the net command to
> send the text to the receiver's computer *need to figure out how to send
> my variables with it.
> system("PAUSE"); //die!
> return 0;
> }
> i know very little about c++ and attempting to teach myself
> any ideas about line 19 anone?
> specifically how can i get the varibles name and text passed along to the
> net send command
>
>
>
> regards and thank you in advance
>
> -len
>
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|