Menu

there have a program with Hex editor

2007-06-27
2012-11-13
  • Nobody/Anonymous

    try to make a binary file

    === Turbo C ++ 3.0 ==
    BYTE randBuf[512];
    int i=0;
        for(i=0;i<512;i++){
            rdnBuf[i] = i%255;
    //rdnBuf[i] = (BYTE)((double)rand() / ((double)RAND_MAX + 1) * 255);

        }

    FILE *pFile;
        pFile = fopen("A.bin","w");
        fwrite(randBuf,sizeof(BYTE),512,pFile);
        fclose(pFile);

    =====================
    ok ,then , open the file by notepad++ and to use hex editor to check the value of the binary file
    the value of 1st line is ....

    00 01 02 03 04 05 06 07 08 09 0d 0a ..............

    The address 0x0A should be 0a... but it look like 0d?

     
    • Nobody/Anonymous

      should be
      pFile = fopen("A.bin","wb");

       
    • Nobody/Anonymous

      sry
      n this case, windows os = 0D 0A
      i think windows auto convert the newline('\n')or 0x0A into 0x0D0A (it's EOL) in text mode.