字符串转整数:
1、int atoi(const char *str);//str 为字符串指针,返回一个整型整数
2、long int atol(const char *str);//str 为字符串指针,返回一个长整型整数
整数转字符串:
1、char* itoa(int value, char *str, int base);
//value 为整型数(10进制),存储在 str 指向的内存,base 规定了转换后的进制(2 或 8 或 10 或 16),返回转换成的字符串指针
将字符串连接在一起:
1、int sprintf(char* str, const char* format, ...);
//用法类似 printf ,只不过它把本应该打印出来的东西存在 str 指向的内存。成功时,返回字符串的长度(不含结尾自动添加的'\0');失败时,返回一个负数。
2、char* strcat(char* destination, const char* source);
//可以理解为先将字符串 destination 末尾的 '\0' 去掉,再将字符串 source 接在后边,返回 destination
//destination 应该有足够的空间用来接字符串,source 也应该注意不能太长。