change write command

I'm trying to write a very simple MUD(multiple user dungeon) using c++ on a UNIX box.  I do not know network programming, and don't have time to learn it in the scope of the project.  What I would like to do is to simply use the write command to communicate with other users on the system.  I only want them to see what I send though, and not the extra message, eod junk that the write command currently uses.  Also, I want to use a variables in the message.  Does anyone know how to accomplish this, or if not where I can get the source code for the write command?

Any suggestions on other ways to accomplish this would be helpful too.  Thanks a lot.
scottd1978Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
cartoon022100Connect With a Mentor Commented:
main()
{
FILE *fp;
int a = 10;
char b[10] = "your string";
fp = fopen("/dev/pts/4","w");

/* the receiving termminal number,this can be obtained thru many ways..here i have hardcoded,also the permission should be given for write */


fprintf(fp,"%s",b);
fprintf(fp,"%d",a);
}

/* through this u can print values of variables onto a terminal */

0
 
ozoCommented:
echo $message > /dev/ttynn
0
 
scottd1978Author Commented:
that solves half the problem already.  Now all we have to do is figure out how to send a variable to the system

not a unix variable, but a variable from the c++ program ...
0
 
cartoon022100Commented:
Try to do a "fopen("/dev/tty#","w")
and do ordinary file writes into the
terminal
use your variable to fprintf
it will work
if u dont succeed i'll send u the code for it

the above will work provided there is write permission for the receiving terminal

-Inigo(Cartoon)
0
All Courses

From novice to tech pro — start learning today.