Heres my code:
void *PrintLine(void *line)
{
printf("Line: #%s\n", (char *)line);
pthread_exit(NULL);
}
int main (int argc, char *argv[])
{
char line[80];
while(fgets(line,sizeof(line),fp))
{
pthread_create(&threads[rt], NULL, PrintLine, (void*)line);
}
fclose(fp);
}
Please dont tell me that running a thread only to print a file line doesn't make sense, I removed a lot of code so its easier to read and understand my problem.
As you would guess this code doesn't work, what should I do to be able to print/use "line" inside the thread?