Have you heard of "while" and "for":
Code:
ntr = fopen ("chat.lsm", "rt");
if(ntr==NULL)
{
sleep(100);
main();
}
This is exactly the "do not call main" that I was talking of earlier. Also, perhaps printing a message to say "file could not be opened" may help the debugging of problems with the file not being present or some such.
Code:
printf("", (unsigned long)count, fclose(textwrite) == 0 ? "succeeded" : "failed");
Huh? What on earth is this meant to do?
Don't use gets - it does not check if the input actually fits, so if someone falls asleep pressing the A key, then your program will crash - use fgets() with stdin as the file.
It is perhaps worse for "name", which can actually quite possibly be longer than 9 characters. My full name (not counting middle-name) is a few characters more than that. Trusing users to READ, UNDERSTAND, AND OBEY instructions such as "10 characters max" is not a good idea in general.
Code:
char text[10000]; /*User inputed message*/
char newtext[10000]; /*Message with display name*/
...
sprintf(newtext,"%s: %s",name,text);
Let's assume that text is actually 9999 characters of content. What will happen to newtext?
Code:
char chat[10000]; /*Contents of chat.lsm*/
...
fgets(chat, 1000000, textread);
Do NOT lie to fgets() as to how big your buffer is.
Code:
int x=1; /*Loop*/
...
while(x==1)
{
x=x+1;
...
If x is a flag to see if you want to loop again or not, why not use x = 0 or x = 2 to make it "not 1". Also, is there any particular reason it is declared as a global variable?
As to how you solve the problem, I think all of my original answer still applies. Either use threads or use non-blocking functions, but learn how to program first. Note, it took me quite some time to learn to program too - but I've been programming since early 1980's now.
--
Mats