생산자 소비자 문제에서 파일 10 행의 버퍼를 어떻게 읽을 수 있는지 말해 주시겠습니까?파일에서 읽고 버퍼에 저장
static char buf[10][256];
void *producer(void *var)
{
char line[256];
int i;
for(;;)
{
if(feof)
break;
for(i=0;i<10, i++)
buf = fgets(line,256, in); // what should be the correct coding here to read from file and store in buffer ?
if (pushInBuffer(&buf))
fprintf(stderr, "Error Consuming");
}
pthread_exit(0);
}
'fgets (buf [i], 256, in);'이 게시물은 http://stackoverflow.com/questions/3501338/c-read-file-line-by-line에 도움이 될 수 있습니다. – user376507