Posted by Pritika on 01:42:00 04-06-2003
Can somebody tell me how to have a chat like environment for my C program? I want people to be able to type to the program and get replies.

Thanks
Posted by Yjo on 03:00:00 04-06-2003
Are you using an HTML/CGI interface for the c code?
(if you're talking about a regular console c app, this is probably not the best forum)
you could have a simple html form with a list box, small text entry box and a submit button. The form would also have one or two hidden fields to keep track of users, and the list box would be used for display only.
Every time the form is submitted, your cgi code would need to identify the chat context (what's gone before, etc) from a hidden ID code in the form (there are other ways to do this), parse the input in the text box, and return a form which looks almost the same but with the text entry box empty, and the code's reply pushed onto the top of the list box. (which, preferably should act as a fixed length queue, and display, for example, the last 10 request/response pairs on the thread)
Hope this is of some help to you,
good luck.