//_65_转换函数
//_65_main.cpp
/*在头文件<stdlib.h>中
将str指向的串转换成双精度浮点值、整型值、长整型值
串中必须含有合法的xxxxxx、xxx、xxxx,一一对应
double atof(const char *str);
int atoi(const char *str);
long int atol(const char *str);
*/
#include <stdio.h>
#include <stdlib.h>
int main()
{
char num1[80],num2[80];
printf("Enter first: ");
gets(num1);
printf("Enter second: ");
gets(num2);
double doubleSum1 = atof(num1);
double doubleSum2 = atof(num2);
double doubleSum3 = doubleSum1 + doubleSum2;
printf("atof(num1) is: %f\n",doubleSum1);
printf("atof(num2) is: %f\n",doubleSum2);
printf("The sum of num1 and num2 is: %f\n",doubleSum3);
printf("Enter third: ");
gets(num1);
printf("Enter fourth: ");
gets(num2);
int intSum1 = atoi(num1);
int intSum2 = atoi(num2);
int intSum3 = intSum1 + intSum2;
printf("atoi(num1) is: %f\n",intSum1);
printf("atoi(num2) is: %f\n",intSum2);
printf("The sum of num1 and num2 is: %f\n",intSum3);
printf("Enter fifth: ");
gets(num1);
printf("Enter sixth: ");
gets(num2);
long int longSum1 = atol(num1);
long int longSum2 = atol(num2);
long int longSum3 = longSum1 + longSum2;
printf("atol(num1) is: %f\n",longSum1);
printf("atol(num2) is: %f\n",longSum2);
printf("The sum of num1 and num2 is: %f\n",longSum3);
system("pause");
return 0;
}