Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
fread returns more than i want
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Franz Jeitler, post: 2438995"] 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 [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
fread returns more than i want
Top