Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #include<stdbool.h>
- #include<errno.h>
- extern int errno;
- int main(int argc, char *argv[])
- {
- /*if(argc != 2) {
- fprintf(stderr, "Invalid input\n");
- exit(1);
- }*/
- FILE* fp;
- char *orig = "func";
- char *new = "printf";
- int ch;
- fp = fopen("code_to_change.c", "r+");
- if(fp = NULL) {
- fprintf(stderr, "Cannot open file\n");
- fclose(fp);
- exit(1);
- }
- else if(errno != 0) {
- fprintf(stderr, "Unexpected error\n");
- fclose(fp);
- exit(1);
- }
- else {
- return 0;
- }
- ch = fscanf(fp, "func");
- if(ch) {
- strcpy(orig, new);
- return 0;
- }
- else if(!ch) {
- fprintf(stderr, "Error blyat\n");
- return 1;
- }
- else {
- printf("Unexpected error\n");
- fclose(fp);
- exit(1);
- fclose(fp);
- /* fp = popen("gcc argv[1] -o compilated", "r");
- if(fp == NULL) {
- fprintf(stderr, "Fuck you bitch!\n");
- pclose(fp);
- return 1;
- }
- pclose(fp); */
- system("gcc code_to_change.c -o changed_code");
- return 0;
- }
Add Comment
Please, Sign In to add comment