F
Franz Jeitler
Hello,
I have some problems with fread.. first, let's see a part of the source
file:
FILE *fp;
char buf[512];
size_t nread;
..
..
while( nread = fread(buf,1,sizeof(buf),fp) )
fwrite(buf,1,nread,stdout);
The code above is working fine, it returns a desired file on the screen.
Now the problem:
------------------
For a file server I need to give back a structure like: <
strcpy(result.text, buf) >;
For easier understanding, temporary I can also write:
< fprintf(stdout, buf) > instead of < fwrite(buf,1,nread,stdout) >.
But now at the end of each part of the file I get some strange characters
and the last block continues again
with the first lines of the file.
So, why does this happen and how can I solve the problem?
Thank's
Franz
I have some problems with fread.. first, let's see a part of the source
file:
FILE *fp;
char buf[512];
size_t nread;
..
..
while( nread = fread(buf,1,sizeof(buf),fp) )
fwrite(buf,1,nread,stdout);
The code above is working fine, it returns a desired file on the screen.
Now the problem:
------------------
For a file server I need to give back a structure like: <
strcpy(result.text, buf) >;
For easier understanding, temporary I can also write:
< fprintf(stdout, buf) > instead of < fwrite(buf,1,nread,stdout) >.
But now at the end of each part of the file I get some strange characters
and the last block continues again
with the first lines of the file.
So, why does this happen and how can I solve the problem?
Thank's
Franz