468,513 Members | 979 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,513 developers. It's quick & easy.

How to extract a byte from file/

1
Hello all

I am not exactly a programmer, but learning VC++ on my own in free time.

I want dialog box to get a file name using m_FileName.GetPathName,

and then read each byte of the file from byte 0 to last byte for operation.

can someone tell me how I can read first byte ..second byte..third byte and so on. The file needs to be read in binary , that much i know.
Oct 9 '06 #1
1 3347
ltgbau
41
Expand|Select|Wrap|Line Numbers
  1. FILE *file=fopen("file.in", "rb");
  2. BYTE buf;
  3. while(feof(file)==FALSE)
  4. {
  5.     int n=fread(&buf, 1, 1, file);
  6.     if(n>0)
  7.     {
  8.         // process here...
  9.     }
  10. }
  11. fclose(file);
  12. file=NULL;
Oct 10 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

17 posts views Thread by Pascal | last post: by
7 posts views Thread by flamesrock | last post: by
3 posts views Thread by Selen | last post: by
5 posts views Thread by Steve | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.