문자열을 5글자만 입력받고 싶은데
char *pc = malloc(sizeof(char) * 6);
while (1) {
scanf("%5s", pc);
printf("%s", pc);
}
이렇게 하면 abcdef 입력하면
abcde
f
이런식으로 버퍼에 남은 문자열이 출력되는데 버퍼 어떻게 다 비우죠 ㅇㅅㅇ
getchar()는 한글자만 없애는거구
문자열을 5글자만 입력받고 싶은데
char *pc = malloc(sizeof(char) * 6);
while (1) {
scanf("%5s", pc);
printf("%s", pc);
}
이렇게 하면 abcdef 입력하면
abcde
f
이런식으로 버퍼에 남은 문자열이 출력되는데 버퍼 어떻게 다 비우죠 ㅇㅅㅇ
getchar()는 한글자만 없애는거구
버퍼 플러시 c언어 한번 찾아본나
플러시는 GCC에선 안먹힌다는데요 ㅇㅅㅇ
https://gall.dcinside.com/board/view/?id=programming&no=1204252