Today
Total
Archives
05-09 20:21
관리 메뉴

tony9402

[C언어] 한 줄 입력 받을 때 어떻게 써야 해요? 본문

알고리즘

[C언어] 한 줄 입력 받을 때 어떻게 써야 해요?

ssu_gongdoli 2021. 10. 17. 17:29
반응형

 

톡방에서 얘기를 하다가 갑자기 블로그에 써놔야겠다는 생각이 들어서 작성하게 되었다. (다시 보니 저기에서 ^가 빠졌긴 했지만 그래도 올바르지 않은 문법이다.)

 

위에 있는 답변을 많이 볼 수 있는데 올바르지 않은 문법이다.

아래 올바른 문법이랑 올바르지 않은 문법을 적어놨다.

char ch[10000];
scanf("%[^\n]", ch); // 올바른 문법

char ch[10000];
scanf("%[^\n]s", ch); // 올바르지 않은 문법

 

 

자세한 내용은 아래 링크를 확인하면 된다.

 

http://www.cplusplus.com/reference/cstdio/scanf/

 

scanf - C++ Reference

function scanf int scanf ( const char * format, ... ); Read formatted data from stdin Reads data from stdin and stores them according to the parameter format into the locations pointed by the additional arguments. The additional arguments should p

www.cplusplus.com

 

반응형

'알고리즘' 카테고리의 다른 글

[백준 23288] 주사위 굴리기2  (2) 2021.10.25
Comments