int
util_add_comma_to_num(const char *str, char *buf, int buflen)
{
int len;
int shift;
/* count given string */
len = strlen(str);
shift = -len;
assert( buflen >= (len + len/3 +1));
while (*str)
{
*buf++ = *str++;
if (++shift && (shift % 3) == 0)
*buf++= ',';
}
*buf = '\0';
return 0;
}출처 : http://kldp.org/node/38269
'잡다한것들전부 > 팁' 카테고리의 다른 글
| cocos2d-x 의 메모리 관리 (0) | 2014.01.13 |
|---|---|
| cocos2d-x 멀티해상도 지원 (0) | 2014.01.13 |
| 숫자에 세자리마다 콤마를 찍는 알고리즘 (0) | 2014.01.10 |
| [좌표] 좌표에 대해서 알아봅시다(convertToWorldSpace) 절대좌표 (0) | 2014.01.10 |
| [디자인패턴] cocos2d-x 싱글톤 싱글턴 패턴 구현 (0) | 2014.01.08 |
| [디버깅] GDB 사용하기 (0) | 2014.01.07 |
Trackback 0 And
Comment 0


