其实并不是严格意义上的劫持控制流。
适用于
要求你自己写头文件的题目,然后给一个测试文件main.c,文件里面引你写的头文件,底下做测试,测完输出结果。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| #include "linkedlist.h" #include <stdio.h> #include <stdlib.h> #include <time.h> #include "linkedlist.h"
#define JUDGE(x, c, s) {\ FILE *fp = fopen(argv[1], "a");\ if ( fp ) {\ fprintf(fp, "%s\t", s);\ if ( x ) {\ credit += c;\ fprintf(fp, "PASS %d %d\n", c, credit);\ } else {\ fprintf(fp, "FAIL 0\n");\ }\ fclose(fp);\ }\ }
|
怒而抢夺你的main
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| #include<stdio.h> #include<stdlib.h> #pragma once
typedef struct { int *content; int size; } Array;
Array array_create(){}; void array_free(Array* array){};
int array_size(const Array *array){}; void array_inflate(Array *array){};
int array_get(const Array *array, int index){}; void array_set(Array *array, int index, int value){};
Array array_clone(const Array *array){};
int main(int argc, char *argv[]) { FILE *fp = fopen(argv[1], "w"); fprintf(fp, "1\n\ 2\n\ 3\n\ 4\n\ 5\n\ 6\n\ 7\n\ 8\n\ 9\n\ 10\n" "10\n"); }
#define main nothing
|
你将获得包括但不限于以下效果: