Some Questions On This Simple Code

Hello, I've written this simple code and I'm stuck. I'm trying to get the code to change the 5th byte of the target file. As of now the first byte is successfully overwritten but I can't figure out how to make it overwrite the 5th byte. If anyone has any suggestions or pointers, it would be greatly appreciated.

Here's the code I'm working with. Thanks

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>

int main(int argc, char **argv) {
const char *file;
const char *am;
FILE *fp;

printf("\n\nIOS Patcher\n");
printf("This is my very first program so cut me some slack if its buggy :)\n\n");
if (argc != 3) {
fprintf(stderr, "Usage: %s IOS.wad [1]Dip patch/[2]Update version\n", argv[0]);
return EXIT_FAILURE;
}

file = argv[1];
if (!(fp = fopen(file, "r+b"))) {
fprintf(stderr, "%s: %s: %s\n", argv[0], file, strerror(errno));
return EXIT_FAILURE;
}
am = argv[2];
if( (argv[2][0] != 'a') && (argv[2][0] != 'm') )
{
printf("Illegal switch. Please use [1]Dip Patch/[2]Update version\n");
return EXIT_FAILURE;
}

if( (argv[2][0] == '1')) {
putc('0', fp);
}
if( (argv[2][0] == '2')) {
putc('R', fp);
}
fclose(fp);
printf("Operation completed successfully.");
return EXIT_SUCCESS;
}
Thanks Kiana. That worked perfectly!! :)
Topic archived. No new replies allowed.