_atoi64, _atoi64_l, _wtoi64, _wtoi64_l

문자열을 64비트 정수로 변환합니다.

구문

__int64 _atoi64(
   const char *str
);
__int64 _wtoi64(
   const wchar_t *str
);
__int64 _atoi64_l(
   const char *str,
   _locale_t locale
);
__int64 _wtoi64_l(
   const wchar_t *str,
   _locale_t locale
);

매개 변수

str
변환할 문자열입니다.

locale
사용할 로캘입니다.

반환 값

각 함수는 입력 문자를 숫자로 해석하여 생성된 __int64 값을 반환합니다. 입력을 해당 형식의 값으로 변환할 수 없는 경우 반환 값은 0 _atoi64 입니다.

함수가 큰 양의 정수 값으로 오버플로되면 반환 I64_MAX됩니다. 함수는 큰 음수 정수 값으로 오버플로되는 경우 반환 I64_MIN 됩니다.

범위를 벗어난 모든 경우 errnoERANGE로 설정됩니다. 전달된 매개 변수가 있으면 NULL매개 변수 유효성 검사에 설명된 대로 잘못된 매개 변수 처리기가 호출됩니다. 계속해서 실행하도록 허용된 경우, 이러한 함수는 errnoEINVAL로 설정하고 0을 반환합니다.

설명

이러한 함수는 문자열을 64비트 정수 값으로 변환합니다.

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

_atoi64에 대한 str 인수의 형식은 다음과 같습니다.

[whitespace] [sign] [digits]

공백 whitespace 또는 탭 문자로 구성되며 무시 sign 됩니다. 더하기(+) 또는 빼기(-)이며 digits 하나 이상의 숫자입니다.

_wtoi64은 와이드 문자를 매개 변수로 사용한다는 점을 제외하고 _atoi64과 동일합니다.

_l 접미사가 있는 이러한 함수 버전은 현재 로캘 대신 전달된 로캘 매개 변수를 사용하는 경우를 제외하고는 동일합니다. 자세한 내용은 Locale을 참조하세요.

기본적으로 이 함수의 전역 상태는 애플리케이션으로 범위가 지정됩니다. 이 동작을 변경하려면 CRT의 전역 상태를 참조하세요.

일반 텍스트 루틴 매핑

Tchar.h 루틴 _UNICODE 정의 _MBCS 되지 않음 _MBCS 정의 _UNICODE 정의
_tstoi64 _atoi64 _atoi64 _wtoi64
_ttoi64 _atoi64 _atoi64 _wtoi64

요구 사항

루틴 필수 헤더
_atoi64, _atoi64_l <stdlib.h>
_wtoi64, _wtoi64_l <stdlib.h> 또는 <wchar.h>

예시

이 프로그램은 _atoi64 함수를 사용하여 문자열로 저장된 수가 숫자 값으로 변환되는 방법을 보여 줍니다.

// crt_atoi64.c
// This program shows how numbers stored as
// strings can be converted to numeric values
// using the _atoi64 functions.
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>

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

    // An example of the _atoi64 function
    // with leading and trailing white spaces.
    str = "  -2309 ";
    value = _atoi64( str );
    printf( "Function: _atoi64( \"%s\" ) = %d\n", str, value );

    // Another example of the _atoi64 function
    // with an arbitrary decimal point.
    str = "314127.64";
    value = _atoi64( str );
    printf( "Function: _atoi64( \"%s\" ) = %d\n", str, value );

    // Another example of the _atoi64 function
    // with an overflow condition occurring.
    str = "3336402735171707160320";
    value = _atoi64( str );
    printf( "Function: _atoi64( \"%s\" ) = %d\n", str, value );
    if (errno == ERANGE)
    {
       printf("Overflow condition occurred.\n");
    }
}
Function: _atoi64( "  -2309 " ) = -2309
Function: _atoi64( "314127.64" ) = 314127
Function: _atoi64( "3336402735171707160320" ) = -1
Overflow condition occurred.

참고 항목

데이터 변환
수학 및 부동 소수점 지원
Locale
_ecvt
_fcvt
_gcvt
setlocale, _wsetlocale
_atodbl, _atodbl_l, _atoldbl, _atoldbl_l, _atoflt, _atoflt_l