문자열 a b c를 입력받고
%lf %c를 입력받아서
a b c
%s %lf %c
(앞 글자끼리 줄맞춤) 해서 출력해야하는데
%4s 요런식으로 맞추는 줄 알았는데
문자열 길이가 입력받는 값에 따라 변해서
내 뇌피셜) 문자열의 길이를 string.h strlen()을 활용해서 변수화하고 *변경자를 활용해서 출력하자!
라고 나온게
fprintf(output_f, "%s %*s %*.*s", "student", name_size, "average", name_size, name_size, "grade\n");
i = 0;
while(1){
stt=fscanf(input_f, "%s %lf %lf", name, &trash, &trash);
if(stt==EOF) break;
fprintf(output_f, "%-*.*s %*.2lf %*.*c\n", name_size, name_size, name, name_size, average[i], name_size, name_size, grade[i]);
i++;
}
fprintf(output_f, "Total average: %.2lf", ttl_avg);
요건데
출력이 내 맘 같지가 않다.. 어떻게 해야하냐..
간단하게 \t 두 세번 넣어서 그냥 정렬해 ㅇㅅㅇ
출력시 name의 길이가 긴 부분만 밀려서 출력되는데 좋은 해결책 없을까요 ㅠㅠ 저도 고민해보고 있겠습니다..