トップページ > キーワード検索 > strtod()
C言語規格
C言語(その他)
プログラム
その他
strtod()
機能 文字列をdouble型の表現に変換する。
定義 #include <stdlib.h>

double strtod ( const char * nptr, char ** endptr );

※C99規格では以下の定義となる
double strtod ( const char * restrict nptr, char ** restrict endptr );
引数
nptr変換する文字列
endptr残りの部分の文字列を示すポインタの格納先を示すポインタ
戻り値 変換された値を返す。
変換が不可能ならば 0 を返す。
正しい値が表現可能な値の範囲外である場合は、HUGE_VALを返し、errnoERANGEの値を格納する。
実装例
#include <stdlib.h>
#include <stdio.h>

int main(void)
{
    double f;
    char *s;
    
    f = strtod("123.45abc", &s);
    
    printf("%f\n", f);
    printf("%s\n", s);
    
    return 0;
}
実行結果
123.450000
abc





inserted by FC2 system