13 lines
271 B
C
13 lines
271 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
int main(int argc, const char *argv[])
|
||
|
{
|
||
|
char *p = "120";
|
||
|
printf("%ld\n", atol(p)); // atol: 转换成长整型
|
||
|
|
||
|
p = "12.3";
|
||
|
printf("%.2f\n", atof(p)); // atof: 转换成浮点数
|
||
|
return 0;
|
||
|
}
|