[완료]fscanf를 이용해 5글자씩만 받는 방법이 있나요?

noblepylon의 이미지

fscanf(fin, "%s", String);

이라고 해버리면 한 단어가 통째로 String배열에 들어가버립니다.
한 단어 통째로가 아닌, 딱 5글자만 받는 방법이 있나요?
fscanf(fin, "%c %c %c %c %c", &String[0], &String[1], &String[2], &String[3], &String[4]);

이렇게 쓰기는 뭔가 지저분해보여서요.
lacovnk의 이미지

       char str[6];
        scanf("%5s", str);

그냥 해봤는데 되네요..

noblepylon의 이미지

정말 간단하군요.
---
"The truth will make you free."(John 8:32)
"I am the way, and the truth, and the life: no one comes to the Father but through Me."(John 14:6)

---
“내게 능력주시는 자 안에서 내가 모든 것을 할 수 있느니라.”(빌립보서 4:13)