當前位置:編程學習大全網 - 網站源碼 - c語言中,輸入壹串數字字符,如何轉化為double類型的

c語言中,輸入壹串數字字符,如何轉化為double類型的

參考代碼:

#include?<stdio.h>

#include?<stdlib.h>

int?main()

{

char?str1[20],?str2[20];

scanf("%s",?str1);

scanf("%s",?str2);

/*使用atof函數轉換*/

printf("%s?+?%s?=?%lf\n",?str1,?str2,?atof(str1)+atof(str2));

return?0;

}

運行效果:

  • 上一篇:電視dvbc和dtmb是什麽意思
  • 下一篇:在ubuntu上寫的QT程序能不能拷貝到windows下運行阿
  • copyright 2024編程學習大全網