va_list 의 사용과 vsprintf 이용 예
#include // for use va_list// global variable char dbgStrings[1024];// sample function void Mydebug(const char *funcName, int line, char *format, ...) { char tempStr[1024] ={0,}; memset(dbgStrings, 0x0, sizeof(dbgStrings)); /* use for vsprintf */ va_list ap; va_start( ap, format ); vsprintf(tempStr, format, ap); va_end(ap); /* add to function name and line number */ sprintf(dbgStrings, "%s() - l..
2009. 7. 19.
[C] fwrite 예제
fwrite를 이용한 파일에 내용 써넣기 예제.. #include #include #include "common.h" void setValue(char *buf) { char tempBuf[64]; memset(tempBuf, 0x00, sizeof(char) * 64); int a = 0; sprintf(tempBuf, "test %d\n", a); strcat(buf, tempBuf); sprintf(tempBuf, "test2 %d\n", a+1); strcat(buf, tempBuf); sprintf(tempBuf, "\n%d\t%d\n%d\t%d\n\n", a+1, a+2, a+3, a+4); strcat(buf, tempBuf); sprintf(tempBuf, "test3 %2d\n", a+5..
2009. 5. 27.