Skip to content

Instantly share code, notes, and snippets.

@ariedro
Created February 24, 2020 18:56
Show Gist options
  • Select an option

  • Save ariedro/792aa9505637a51c9f24ec4f536bcc3f to your computer and use it in GitHub Desktop.

Select an option

Save ariedro/792aa9505637a51c9f24ec4f536bcc3f to your computer and use it in GitHub Desktop.
# include <stdio.h>
# include <stdlib.h>
int main (int argc, char* argv[]) {
if(argc < 3) {
printf("Usage: offseter [FILE] [OFFSET]\n");
return 1;
}
unsigned char offset = atoi(argv[2]);
FILE *fi, *fo;
unsigned char c;
fi = fopen(argv[1], "r");
if(!fi) {
printf("%s: No such file or directory\n", argv[1]);
return 1;
}
fo = fopen("out.txt", "w");
while(!feof(fi)) {
c = fgetc(fi);
fputc(c + offset, fo);
}
fclose(fi);
fclose(fo);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment