Thread: Hex Editing help and information please...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    45

    Hex Editing help and information please...

    Ive written a short and simple DOS General C program (Dev-C++) to lsit the files in my working directory, then read and print out the hex of any file name entered (it takes the file entered, reads the actual file).

    Now, the line number is listed in hex perfectly fine, but the hex of the string on that line is the same for every line, and not really in hex.

    Here is my hex printing program:
    Code:
    void FileRead(const char* FilePath) {
         auto char line[200];
         auto FILE *fp;
         int count = 1;
         if((fp = fopen(FilePath, "rb"))==NULL) { printf("%s does not exist!", FilePath);
         } else {
         printf("\n\nNow Opening: %s\n", FilePath);
         while ( fgets(line, sizeof line, fp) != NULL)
         {  
                                    printf("0x%08x:  %10.8x\n",count,line);
                                    count++;
                                    if((getch())=='\r') 
                                                             break;
         }
    }
    }
    The output puts the line number in hex and the string in the same hex over and over even tho its different.

    Now, once that is fixed, id like to be able to edit that printed data...

    My guess is to feed each of those lines into an array (check) print them out, line by line, making a line identifier to see what line your on (check) maybe make it a 2d array to show the current position in each line? (So a 3d array? is that possible? hexFile[totalLines[Currentline][posInLine?])

    Could someone just give me a code snippet for editing hex in a file? I really really dont want to spend a week asking and taking forever to finally find an example to learn from.
    Last edited by SG57; 06-24-2006 at 02:02 AM.

Popular pages Recent additions subscribe to a feed