471,850 Members | 1,056 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,850 software developers and data experts.

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 3580
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
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.