오류좀 해결해주세요 ㅠㅠ 급함
봄
read_data 함수를 텍스트에 저장하여 read_out 으로 출력하는 것입니다.read_data 함수를 텍스트에 저장하여 read_out 으로 출력하는 것입니다.질문 내용 : 텍스트가 깨져서 나옵니다. 뭐가 잘못됬는지 설명좀 해주세요 제가 c언어 초짜입니다.ㅠㅠ
#include stdio.h
#include stdlib.h
#include string.h
struct student
{
char name[10];
int kor, eng, math, tot;
double avg;
}si;
void read_data(struct student kim[5]);
void print_out(struct student stu[]);
int main()
{
struct student stu[5];
read_data(stu);
print_out(stu);
return 0;
}
void read_data(struct student kim[5])
{
int i;
struct student s0={kim, 95, 95, 90, 0, 0.0};
struct student s1={park, 90, 85, 90, 0, 0.0};
struct student s2={lee, 95, 95, 95, 0, 0.0};
struct student s3={hong, 85, 85, 90, 0, 0.0};
struct student s4={oh, 85, 85, 85, 0, 0.0};
for(i=0;i5;i++)
{
si.tot = (si.kor + si.eng + si.math);
si.avg = (double)(si.kor + si.eng + si.math)/3;
}
}
void print_out(struct student stu[])
{
int i;
file *fp = null;
fp=fopen(data.txt, w);
if(fp == null)
{
printf(파일 열기 실패\n);
}
for(i=0;i5;i++)
{
fprintf(fp, %-10s %3d %3d %3d %3d %6.2f\n,
stu[i].name, stu[i].kor, stu[i].eng, stu[i].math, stu[i].tot,
stu[i].avg);
}
fclose(fp);
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2695766 | 달팽이 배열 어디서 틀렸는지 모르겠습니다ㅠㅠ | 연분홍 | 2025-05-23 |
2695738 | fopen과fclose질문~~ (5) | 희선 | 2025-05-23 |
2695707 | 3의 배수 나타내기. (2) | 수리 | 2025-05-23 |
2695626 | 피보나치수열 과제 때문에 질문 드립니다. (6) | 옆집언니 | 2025-05-22 |
2695595 | 포인트공부중입니다 int형에서 4=1 인가요? (3) | 족장 | 2025-05-22 |
2695567 | 드라이브 고유번호를 가져오는 함수 (2) | 초코맛사탕 | 2025-05-21 |
2695533 | 음수의 산술변환! 질문이요 ㅠㅠ... (4) | 꽃여름 | 2025-05-21 |
2695506 | 구조체 배열 이용 도서목록 출력 프로그램 (1) | 가을귀 | 2025-05-21 |
2695450 | c언어 함수 질문이요.... | 이슬비 | 2025-05-20 |
2695403 | VirtualAlloc함수 및 메모리 질문 | 크리에이터 | 2025-05-20 |
2695355 | c언어 for함수 | 미쿡 | 2025-05-19 |
2695327 | 안녕하세요 제가 이번에 좀 큰 프로그램을.. | 악당 | 2025-05-19 |
2695295 | mutex동기화의 thread기반 채팅 서버소스 질문입니다 | 그루터기 | 2025-05-19 |
2695270 | 질문이요..swap 관한겁니다..ㅠㅠ (3) | 콩알녀 | 2025-05-19 |
2695244 | 노땅초보궁금한게 하나 있는데요..반복문(while문)초보자질문 (6) | 큰꽃늘 | 2025-05-18 |
2695166 | do while 문 어떤것이잘못된건지 모르겠어요 (2) | 아이폰 | 2025-05-18 |
2695122 | 구조체에 대해 물어보고 싶은게 있습니다 ^^^.. (7) | 수련 | 2025-05-17 |
2695091 | txt 파일 입출력 후 2차 배열에 저장하기입니다. (3) | 헛장사 | 2025-05-17 |
2695063 | 수도요금 프로그램좀 짜주세요. | 시내 | 2025-05-17 |
2695033 | 답변좀요ㅠㅠ (1) | 비사벌 | 2025-05-16 |