C语言分割字符串函数strtok和atof的使用
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char name[] = "123.4,456.78,4569.23";
char *p = strtok(name,",");
while(p!=NULL){
printf("%lf\n",atof(p));
p = strtok(NULL,",");
}
printf("Hello world\n");
return 0;
}
还没有评论,来说两句吧...