atof, _atof_l, _wtof, _wtof_l

이중으로 문자열을 변환 합니다.

double atof(
   const char *str 
);
double _atof_l(
   const char *str,
   _locale_t locale
);
double _wtof(
   const wchar_t *str 
);
double _wtof_l(
   const wchar_t *str,
   _locale_t locale
);

매개 변수

  • str
    변환 될 문자열입니다.

  • locale
    사용 하는 로캘.

반환 값

각함수는 반환의 double 값에서 입력된 문자를 숫자로 해석 하 여 생성 합니다.입력 값을 해당 형식으로 변환 될 수 없는반환 값은 0.0입니다.

모든 범위를 벗어난 경우, errno로 설정 됩니다 ERANGE.매개 변수전달 된 경우 NULL, 설명에 따라잘못된매개 변수처리기가 호출 매개 변수 유효성 검사. 실행을 계속 수 있으면 이러한 함수를 설정 errno 에 EINVAL 및 0을 반환 합니다.

설명

이러한 함수는변환하다문자열 배정밀도, 부동 소수점 값입니다.

입력된 문자열의 지정 된 형식의 숫자 값으로 해석 될 수 있는 문자시퀀스입니다.함수숫자의 일부로 인식할 수 없는 첫 번째 문자에서 입력된 문자열 읽기를 중단 합니다.이 문자는null 문자('\ 0' 또는 '\ 0' L)는 문자열을 종료 합니다.

str인수를 atof_wtof양식다음과 같습니다:

[whitespace] [sign] [digits] [.digits] [ {d | D | e | E }[sign]digits]

A whitespace 는 무시 됩니다; 공백이 나 탭 문자 중 구성 됩니다. sign하나는 더하기 (+) 또는 빼기 (-) 및 digits 하나 이상의10진이 하 자릿수입니다.숫자가10진지점 전에 나타나는 경우 하나 이상의10진지점 다음 표시 되어야 합니다.10진자릿수는 소개 글자만 지가 나올 수 있습니다 (d, D, e, 또는 E) 및 선택적으로 부호 있는10진정수.

버전으로 이러한 함수는 _l 접미사는 현재로캘대신 전달 된로캘매개 변수를 사용할 경우를 제외 하 고 동일 합니다.

일반 텍스트 루틴 매핑

TCHAR입니다.H 루틴

_UNICODE 및 _Mbcs가 정의 되지 않았습니다.

_Mbcs가 정의

_Unicode가 정의

_tstof

atof

atof

_wtof

_ttof

atof

atof

_wtof

요구 사항

Routine(s)

필수헤더

atof

<math.h> 및 <stdlib.h>

_atof_l

<math.h> 및 <stdlib.h>

_wtof, _wtof_l

<stdlib.h> 또는 <wchar.h>

예제

이프로그램어떻게 사용 하 여 숫자 값을 문자열로 저장 된 숫자를 변환할 수 있습니다 보여 줍니다 있는 atof함수입니다.

// crt_atof.c
//
// This program shows how numbers stored as 
// strings can be converted to numeric
// values using the atof function.

#include <stdlib.h>
#include <stdio.h>

int main( void )
{
    char    *str = NULL;
    double  value = 0;

    // An example of the atof function
    // using leading and training spaces.
    str = "  3336402735171707160320 ";
    value = atof( str );
    printf( "Function: atof( \"%s\" ) = %e\n", str, value );

    // Another example of the atof function
    // using the 'd' exponential formatting keyword.
    str = "3.1412764583d210";
    value = atof( str );
    printf( "Function: atof( \"%s\" ) = %e\n", str, value );

    // An example of the atof function
    // using the 'e' exponential formatting keyword.
    str = "  -2309.12E-15";
    value = atof( str );
    printf( "Function: atof( \"%s\" ) = %e\n", str, value );

}
  

해당 .NET Framework 항목

참고 항목

참조

데이터 변환

부동 소수점 지원

로캘

_ecvt

_fcvt

_gcvt

setlocale을 _wsetlocale

_atodbl, _atodbl_l, _atoldbl, _atoldbl_l, _atoflt _atoflt_l