#include stdio.h#include stdlib.h#include string.hint main () {float val;char str[20];
编程学习网为您整理以下代码实例,主要实现:C语言库atof()函数,希望可以帮到各位朋友。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main () {
float val;
char str[20];
strcpy(str, "98993489");
val = atof(str);
printf("String value = %s, float value = %f\n", str, val);
strcpy(str, "yiibai.com");
val = atof(str);
printf("String value = %s, float value = %f\n", str, val);
return(0);
}