[완료] scanf에서 띄어 쓰기가 인식이 가능합니다... ㅋㅋ

nathaniel7687의 이미지

scanf에서 띄어 씌기 인식이 가능하게 하는 방법이

scanf("%[^\n]s",&arr);

이것과 같은데요...

저렇게 쓰는걸 뭐라고 부르는지 알려주세요 !

bluekyu의 이미지

[^\n] 도 서식 문자(conversion specifiers)의 일부입니다. scanf manpage 를 보시면 엄청 다양한 서식문자 기술 방법이 있습니다.
아래는 man scanf 시에 나오는 부분 중에 [ 서식 문자에 대한 내용입니다.


[             Matches a nonempty sequence of characters from the specified set  of  accepted  characters;  the  next
              pointer must be a pointer to char, and there must be enough room for all the characters in the string,
              plus a terminating null byte.  The usual skip of leading white space is suppressed.  The string is  to
              be made up of characters in (or not in) a particular set; the set is defined by the characters between
              the open bracket [ character and a close bracket ] character.  The set excludes  those  characters  if
              the  first  character  after  the open bracket is a circumflex (^).  To include a close bracket in the
              set, make it the first character after the open bracket or the circumflex; any other position will end
              the  set.   The  hyphen character - is also special; when placed between two other characters, it adds
              all intervening characters to the set.  To include a hyphen, make it the  last  character  before  the
              final  close  bracket.   For  instance,  [^]0-9-] means the set "everything except close bracket, zero
              through nine, and hyphen".  The string ends with the appearance of a character not in the (or, with  a
              circumflex, in) set or when the field width runs out.

/*** Signature ******************
* blog: http://blog.bluekyu.me/ *
********************************/

hgi01982의 이미지

이라 부르지 싶네요..

익명 사용자의 이미지

표준에 정의되어 있구요.

정규표현식보다 기능이 제한적이지요.

http://kldp.org/node/62473

nathaniel7687의 이미지

맞습니다 !!
정규표현식!! 이게 정답이였어요 !!!

이걸 찾고 있었습니다. !!! 감사합니다!!