atoi
函數(shù)將字符串轉(zhuǎn)換為整型,例如:char str[] = "12345";
int num = atoi(str);
atol
函數(shù)將字符串轉(zhuǎn)換為長整型,例如:char str[] = "1234567890";
long num = atol(str);
atof
函數(shù)將字符串轉(zhuǎn)換為浮點(diǎn)型,例如:char str[] = "3.14";
float num = atof(str);
sprintf
函數(shù)將整型轉(zhuǎn)換為字符串,例如:int num = 12345;
char str[10];
sprintf(str, "%d", num);
sprintf
函數(shù)將長整型轉(zhuǎn)換為字符串,例如:long num = 1234567890;
char str[20];
sprintf(str, "%ld", num);
sprintf
函數(shù)將浮點(diǎn)型轉(zhuǎn)換為字符串,例如:float num = 3.14;
char str[10];
sprintf(str, "%f", num);