• Advertisement
Sign in to follow this  

I need help with fread

This topic is 4720 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I open a file thats 6 mb big. I try to read each "short" one at a time. I count how many times I do, and the count my program spits back is 1k and some change. If my math is correct, I should get around 3 million right? 1k * 2( bytes a short) = 2k bytes < 6 m bytes. I do not know how to "post" code but I will try. <code> FILE *tfile; unsigned short buffer = 0; short data[32]; unsigned int c = 0; unsigned int i = 0; unsigned int total = 0; unsigned int sum = 0; bool match = false; clear(data); tfile = fopen("c://test.mp3","r"); while ( fread( &buffer, sizeof(short), 1, tfile) >= 1) { </code> Any Ideas? thanks

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by illadel4life
I do not know how to "post" code but I will try.

Without the spaces:

[ code][ /code]
FILE *tfile;
unsigned short buffer = 0;
short data[32];
unsigned int c = 0;
unsigned int i = 0;
unsigned int total = 0;
unsigned int sum = 0;
bool match = false;

clear(data);

tfile = fopen("c://test.mp3","r");


while ( fread( &buffer, sizeof(short), 1, tfile) >= 1) {



[ source][ /source]

FILE *tfile;
unsigned short buffer = 0;
short data[32];
unsigned int c = 0;
unsigned int i = 0;
unsigned int total = 0;
unsigned int sum = 0;
bool match = false;

clear(data);

tfile = fopen("c://test.mp3","r");


while ( fread( &buffer, sizeof(short), 1, tfile) >= 1) {


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement