c語言atof
Ⅰ c語言中atio和atof怎麼用啊
函數名:
atoi
功
能:
把字元串轉換成長整型數
用
法:
int
atoi(const
char
*nptr);
程序例:
#include
<stdlib.h>
#include
<stdio.h>
int
main(void)
{
int
n;
char
*str
=
"12345.67";
n
=
atoi(str);
printf("string
=
%s
integer
=
%d\n",
str,
n);
return
0;
}
-----------------------------------------------
函數名:
atof
功
能:
把字元串轉換成
浮點數
用
法:
double
atof(const
char
*nptr);
程序例:
#include
<stdlib.h>
#include
<stdio.h>
int
main(void)
{
float
f;
char
*str
=
"12345.67";
f
=
atof(str);
printf("string
=
%s
float
=
%f\n",
str,
f);
return
0;
}
Ⅱ c語言 atof函數
機器誤差,123.400000就可以
Ⅲ c語言atof函數的一些問題
emmm,我什麼都看看不清,只知道atof函數在使用的時候要進行聲明,不然默認返回int型,atol也是,要了解詳情的話,就網路吧
Ⅳ C語言中的atof的用法
//把字元串轉換成浮點數 //double atof(char *)
#include <stdio.h>
#include <stdlib.h>
void main()
{
float f;
char *str="12345";
f=atof(str);
printf("%f\n",f);
}
Ⅳ c語言中atof 和atoi是什麼意思
分別是字元串轉換成浮點型數和字元串轉換成整形數。
Ⅵ c語言,關於atof()函數
經我測試,應該是你沒#include 「stdlib.h」,只#include 「stdio.h」不會報錯,但是atof輸出有問題。但奇怪的是atoi不會出現這個問題。
Ⅶ C語言中 double atof(char *) 是啥意思
(char*)指以「\0」為結束的字元串!你是不是要找某個字元串的地址?
Ⅷ C語言atof函數怎麼用
你這個應該用%f直接讀.
如果用atof
則需要定義x為字元數組.
可以這樣
char
x[100];
float
t;
scanf("%s",x);
if(strcmp(x,
"stop")==0)
break;
t=atof(x);
sum=sum+t;