我试过这个:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
FILE *txt1;
char tam[13];
char tam1[13];
char tam2[13];
txt1 = fopen("C:/Users/Hugo/Documents/C/in2.txt","r");
if(txt1 == NULL)
{
printf("No se puede leer el archivo");
return 0;
}
fgets(tam1,sizeof(tam1), txt1);
double c = atof(tam1);
printf("%f",c);
当我调试时:tam1
是“3.1415926535”但它会打印:
0.000000