面试题的常客:
1 #include<stdio.h>
2 #include<stdint.h>
3 #include<malloc.h>
4 uint64_t char_to_num(char *str);
5 char * num_to_char(uint64_t num);
6 int main(void)
7 {
8 char *str = "123456";
9 uint64_t num = 123456;
10 char *s;
11 printf("%lld
",char_to_num(str));
12 printf("%s
",s=num_to_char(num));
13 free(s);
14 return 0;
15 }
16 /*字符串转数字*/
17 uint64_t char_to_num(char *str)
18 {
19 char *s = str;
20 short count = 0;
21 uint64_t lastnum = 0;
22 while (*s != '