당신이 scanf
에 대한 documentation을 살펴 경우
C string that contains a sequence of characters that control how characters extracted from the stream are treated:
Whitespace character: the function will read and ignore any whitespace characters
encountered before the next non-whitespace character (whitespace characters include
spaces, newline and tab characters -- see isspace). A single whitespace in the format
string validates any quantity of whitespace characters extracted from the stream
(including none).
Non-whitespace character, except format specifier (%): Any character that is not
either a whitespace character (blank, newline or tab) or part of a format specifier
(which begin with a % character) causes the function to read the next character
from the stream, compare it to this non-whitespace character and if it matches,
it is discarded and the function continues with the next character of format. If the
character does not match, the function fails, returning and leaving subsequent
characters of the stream unread.
Format specifiers: A sequence formed by an initial percentage sign (%) indicates a
format specifier, which is used to specify the type and format of the data to be
retrieved from the stream and stored into the locations pointed by the additional
arguments.
당신은 공백 문자는 무시받을 것을 알 수 있습니다.
'는 –
@BasileStarynkevitch 예 (자원 고갈, 즉 메모리 부족에 대한 물론 제외) 현재의 행의 길이를 제한하지 않기 때문에 getline'는 fgets' '보다 더 나은,하지만 그건 **하지 ** 표준 C> o < – ikh