且看一个demo:
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 |
int do_sth(int type) { char *errstr; switch(type) { case 1: errstr = "Error";break case 2: errstr = "Warn";break case 3: errstr = "Info";break case 4: errstr = "Debug";break default: return 0; } if (...) {..} if (...) { ..; fprintf(stdout, "%s %s", errstr, ...); return 1; } if (...) { return 1;} if (...) { fprintf(stderr, "%s %s", errstr, ...); } ... return 0; } |
问题: 如何在errst …