... void test(char* input, char* output, char* result, void (*prc)(void)) { FILE *comp1, *comp2; char c1, c2; int line=1; freopen(input, "r", stdin); freopen(output, "w", stdout); prc(); freopen("CON", "r", stdin); freopen("CON", "w", stdout); comp1 = fopen(output,"r"); comp2 = fopen(result,"r"); while (c1 != EOF && c2 != EOF) { c1 = getc(comp1); c2 = getc(comp2); if(c1 == '\\n' && c2 == '\\n') line++; if(c1 != c2 && c1 != '\\n' && c2 != '\\n') { printf("Testing %s : FAILED (line %d)\\n", input, line); exit(1); } } printf("Testing %s : SUCCESSED\\n", input); return; } ... int main() { test("1\\i.txt", "1\\o.txt", "1\\r.txt", process); return 0; }



문제 풀 때 테스트함수 만들어 놓고 푸니깐 세상 편하네. 앞으로 복붙해서 써야겠다.

+ 내가 봐도 코드가 개떡 같은데 조언해주실 분?