Skip to content

Instantly share code, notes, and snippets.

@Fatpandac
Created July 31, 2021 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fatpandac/5645cb2d963bbdc03d78b4ac136b8bec to your computer and use it in GitHub Desktop.
Save Fatpandac/5645cb2d963bbdc03d78b4ac136b8bec to your computer and use it in GitHub Desktop.
from 《征服C指针》
#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