Created
July 31, 2021 14:25
-
-
Save Fatpandac/5645cb2d963bbdc03d78b4ac136b8bec to your computer and use it in GitHub Desktop.
from 《征服C指针》
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdarg.h> | |
/* #define DEBUG */ | |
#ifdef DEBUG | |
#define DEBUG_WRITE(args) DebugWrite args | |
#else | |
#define DEBUG_WRITE(args) | |
#endif | |
void DebugWrite(char *fmt,...) | |
{ | |
va_list ap; | |
va_start(ap,fmt); | |
vfprintf(stderr,fmt,ap); | |
va_end(ap); | |
} | |
int sum(int times) | |
{ | |
DEBUG_WRITE(("%d\n",times)); | |
return (times) ? times + sum(times - 1) : 0; | |
} | |
int main() | |
{ | |
printf("%d",sum(10)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment