#include<stdio.h>
参考一下这程序
#include<string.h>
#define M 20
int main()
{
char a[M],flag=0,k=1;
int i=0;
double sum1=0.0,sum2=0.0;
printf("Input:");
gets(a);
if(a[0]=='-')
{
k=-1;
i=1;
}
for(;a[i]!='.' && a[i]!='\0';i++)
sum1=sum1*10+a[i]-'0';
if(a[i]!='\0')
for(i=strlen(a)-1;a[i]!='.';i--)
sum2=sum2*0.1+(a[i]-'0')*0.1;
printf("the number is %lf\n",k*(sum1+sum2));
return 0;
}