How to extract a byte from file/

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fannj
    New Member
    • Oct 2006
    • 1

    How to extract a byte from file/

    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.GetP athName,

    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.
  • ltgbau
    New Member
    • Sep 2006
    • 41

    #2
    Code:
    FILE *file=fopen("file.in", "rb");
    BYTE buf;
    while(feof(file)==FALSE)
    {
    	int n=fread(&buf, 1, 1, file);
    	if(n>0)
    	{
    		// process here...
    	}
    }
    fclose(file);
    file=NULL;

    Comment

    Working...