基本上,我有这个功能。在 fgets 之后,我希望父母通过将其 play 变量更改为 0 来让孩子停止。我该怎么做?
void readQuestion(char * question) {
int play = 1;
char inputline[256];
int s;
char * holder;
int p = fork();
if (p == 0) {
while(play) {
holder = strsep(&question," ");
if(holder) {
printf("%s\n",holder);
sleep(1);
}
else{
play = 0;
}
}
}
else {
fgets(inputline,256,stdin);
printf("%s",inputline);
kill();
}
}