입력이 1,000,000 을 넘지 않는다라고 되어 있으니... 1,000,000 이 입력으로 올 수 있고, 이 경우
null character 를 위한 공간을 위해서 char s[1000001]; 로 할당해주셔야 합니다.
getline() 함수의 reference 를 읽어보면 아래 두 줄에 언급된 내용이 있습니다.
A null character ('\0'
) is automatically appended to the written sequence if n is greater than zero, even if an empty string is extracted.
Maximum number of characters to write to s (including the terminating null character).
sizeof(s) 로 전달되는 값이 1,000,000 이기 때문에 null character 자리를 빼고 999,999 개의 문자만 입력으로 받을 수가 있습니다.
dhedaa 7년 전