Purtroppo non risco a capire l' "errore di segmentazione (core dump creato)" che ricevo:
Questo codice che tiporto qui sotto funziona benone:
void *delcacchi(void)
}
FILE *fp;
char readbuf[80];
......................
fp = fopen(FIFO_FILE, "r"); // now open the fifo file
}
printf("Receiving...\n");
// while we can read (up to 9) chars from the fifo...
// Note: readbuf[] will be nul-terminated and will
// include any newlines read from the pipe. since
// we are reading so few bytes at once (9) it will
// take several iterations of the 'while loop' to read
// any long lines written to the pipe by clients.
while(NULL != fgets(readbuf, 10, fp))
{
// print the string just read to my stdout
printf("%s", readbuf);
fflush(stdout);
}
fclose(fp); // close the fifo file
remove(FIFO_FILE); // delete the fifo file
fprintf(stderr, "Pipe server terminating.\n");
return(0);
}
mentre questo che dovrebbe essere suo gemello .... con l'aggiunta delle funzioni strtok ... mi blocca il pgr e mi genera "OOOOrrore di segmentazione (core dump creato) " :
void *delcacchi(void)
}
FILE *fp;
char readbuf[80];
char *rf1, *rf2;
...........
fp = fopen(FIFO_FILE, "r"); // now open the fifo file
}
printf("Receiving...\n");
// while we can read (up to 9) chars from the fifo...
// Note: readbuf[] will be nul-terminated and will
// include any newlines read from the pipe. since
// we are reading so few bytes at once (9) it will
// take several iterations of the 'while loop' to read
// any long lines written to the pipe by clients.
while(NULL != fgets(readbuf, 10, fp))
{
// print the string just read to my stdout
printf("%s", readbuf);
rf1 = strtok(readbuf, " ");
rf2 = strtok(0, " ");
py1 = atof ( rf1);
pz1 = atof ( rf2);
//printf("%f\n", py1);
//printf("%f\n", pz1);
//goto ridipingi;
fflush(stdout);
}
fclose(fp); // close the fifo file
remove(FIFO_FILE); // delete the fifo file
fprintf(stderr, "Pipe server terminating.\n");
return (0);
}
Qualche buon'anima riuscirebbe a illuminarmi??