Работаю через PuTTY. когда ввожу строку, которая записывается в файл, а после должна отправится всем активным пользователям, то в фалй записывается только первое слово строки, а нужно всю.
| Код | #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <signal.h> void menu(){ printf("1.Enter string\n"); printf("2.Exit"); } int main(){ int st,head; int z; char *group; chat *text[255]; while(true){ system("clear"); menu(); scanf("%d", &z); switch(z){ case 1: signal(SIGCHLD,SIG_IGN); if (fork()==0){ char *str; str=(char*)execlp("echo","echo","Enter message string",0); wait(&st); printf("%s",str); } scanf("%s",&text); wait(&st); FILE *file; if((file=fopen("message.txr","w"))==NULL) printf("File not create or open\n"); else { fprintf(file,"%s\n",text); } fclose(file); if(fork()==0){ head=execlp("wall","wall","message.txt",0); wait(&st); } scanf ("%d",&st); break; case 2: return 0; break; } } scanf("%d",&st); }
|
|