OSDN Git Service
(root)
/
lib1stclass
/
main.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
VER0.1.0
[lib1stclass/main.git]
/
itoa.c
1
#include <string.h>
2
3
#ifdef __cplusplus
4
#include "1stclass.hpp"
5
int firstclass::itoa(int n, char s[]){
6
#else
7
#include "1stclass.h"
8
int itoa(int n, char s[]){
9
#endif
10
int i, sign;
11
if ((sign = n) < 0)
12
n = -n;
13
i = 0;
14
do { // generate digits in reverse order
15
s[i++] = n % 10 + '0'; // get next digit
16
} while ((n /= 10) > 0); // delete it
17
if (sign < 0)
18
s[i++] = '-';
19
s[i] = '\0';
20
reverse_char(s);
21
return 0;
22
}