chat simulation

Hi iam new to c programming and i have some problems with this program, i would like your help in how about to do this, i want to keep this as simple as possible using only #include<stdio.h>, what i have so far is that it should be done with arrays and a queue, the server will queue all the messages and then send them to the the other clients.

The Client will randomly generate some text and send it to the Server
the Server will then echo the text to all Clients including the name of
the Client sending the message. This will then be displayed by each of
the Clients that are attached to the Server.
Server should continuously loop and accept messages from Clients
and then echo them. Each client gets a unique name which will be passed to
the server at the time when the connection is established.

Run one server and ten clients for at least 100 distinct messages from all clients.

First off, you may want to edit your post...seeing everything in code tags is really weird and awkward...

As for the Queue thing, a Queue is really just an array with a "front" and a "back". This can be anywhere you want, but typically your front will be the first element, and the back will be the last element. When you enqueue an element, you add it to the end of the list. When you dequeue an element, you remove it from the front of the list.

Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction

More questions?

Thanks i have for the advice i edited my post. Can some one explain how to queue a string into array?

1. What iam thinking is just dealing with two functions one for the client1, that will made of a string and then this string will be store in the server function in a form of a queue fifo, does any know a website that explains queues?
2. The server funcition will distribute the string from client1 to all the other clients.
3. Can some one help me improve this code, becuase is not working. Please tell me if iam going in the right path. Thanks for your help.

You could implement an efficient queue in terms of an array, using a circular buffer. A well-implemented circular buffer would allow for huge event queues up into the thousands and is expressly designed for this purpose.

How do i do queues with an array of string?

Hi everyone thanks for your comments, i understand the logic of the program but when it comes to the actual work i dont have the minimum idea in how to implement a queue with an array or a circular buffer i have done some research online but i havent found any simple code example that will help me to understand this topic. Can some one give me another site or explain it to me?

how i do a queue?

can you give me any code example in how a queue works with strings? I understand the logic you give me but how to do it in actual code is my problem? do you have any example similar to the one you gave me or something similar to this problem?

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell