_cputs, _cputws

콘솔에 문자열을 배치합니다.

Important

이 API는 Windows 런타임에서 실행되는 애플리케이션에서 사용할 수 없습니다. 자세한 내용은 유니버설 Windows 플랫폼 앱에서 지원되지 않는 CRT 함수를 참조하세요.

구문

int _cputs(
   const char *str
);
int _cputws(
   const wchar_t *str
);

매개 변수

str
출력 문자열입니다.

반환 값

성공하면 _cputs가 0을 반환합니다. 함수가 실패하면 0이 아닌 값이 반환됩니다.

설명

_cputs 함수는 str이 가리키는 null 종료 문자열을 콘솔에 직접 씁니다. CR-LF(캐리지 리턴 라인 피드) 조합은 문자열에 자동으로 추가되지 않습니다.

이 함수는 해당 매개 변수의 유효성을 검사합니다. 이 경우 str 매개 변수 유효성 검사에 설명된 대로 잘못된 매개 변수 처리기가 호출NULL됩니다. 실행을 계속할 errno 수 있는 경우 ,로 설정 EINVAL되고 -1이 반환됩니다.

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

일반 텍스트 루틴 매핑

Tchar.h 루틴 _UNICODE 정의 _MBCS 되지 않음 _MBCS 정의 _UNICODE 정의
_cputts _cputs _cputs _cputws

요구 사항

루틴에서 반환된 값 필수 헤더 선택적 헤더
_cputs <conio.h> <errno.h>
_cputws <conio.h> <errno.h>

호환성에 대한 자세한 내용은 호환성을 참조하세요.

라이브러리

모든 버전의 C 런타임 라이브러리입니다.

예시

// crt_cputs.c
// compile with: /c
// This program first displays a string to the console.

#include <conio.h>
#include <errno.h>

void print_to_console(char* buffer)
{
   int retval;
   retval = _cputs( buffer );
   if (retval)
   {
       if (errno == EINVAL)
       {
         _cputs( "Invalid buffer in print_to_console.\r\n");
       }
       else
         _cputs( "Unexpected error in print_to_console.\r\n");
   }
}

void wprint_to_console(wchar_t* wbuffer)
{
   int retval;
   retval = _cputws( wbuffer );
   if (retval)
   {
       if (errno == EINVAL)
       {
         _cputws( L"Invalid buffer in wprint_to_console.\r\n");
       }
       else
         _cputws( L"Unexpected error in wprint_to_console.\r\n");
   }
}

int main()
{
   // String to print at console.
   // Notice the \r (return) character.
   char* buffer = "Hello world (courtesy of _cputs)!\r\n";
   wchar_t *wbuffer = L"Hello world (courtesy of _cputws)!\r\n";
   print_to_console(buffer);
   wprint_to_console( wbuffer );
}
Hello world (courtesy of _cputs)!
Hello world (courtesy of _cputws)!

참고 항목

콘솔 및 포트 I/O
_putch, _putwch