문자열을 5글자만 입력받고 싶은데


char *pc = malloc(sizeof(char) * 6);


while (1) {

scanf("%5s", pc);

printf("%s", pc);

}


이렇게 하면 abcdef 입력하면

abcde

f


이런식으로 버퍼에 남은 문자열이 출력되는데 버퍼 어떻게 다 비우죠 ㅇㅅㅇ

getchar()는 한글자만 없애는거구