제발 좀 도와주세요..ㅠㅠ..파일입출력..
착히
파일 입출력질문 요약 :메모장을 읽어드릴때요..질문 내용 :
--
fname.txt
-----------------------
1 S1 10 5 5500
2 S1 26 12 5500
3 S2 20 3 6300
4 S6 90 32 4800
5 S6 2 1 4800
------------------------
메모장에 이렇게 저장을 하구요 밑에 프로그램의 디렉토리에 넣고 프로그램을 실행 시켰는데
파일이 없다는 말만 계속 뜨네요..내일이 시험인데 제발 설명좀 해주세요.밑에 프로그램은 오류가 없는거 같은데
위에 txt파일에 제가 자료를 잘못 썼나요??
#includestdio.h
#includestring.h
struct result{
char name[10];
int a;
int b;
int c;
int d;
};
typedef struct result result;
void printresult(result* result, int SIZE);
void main(){
int i;
char fname[]= input.txt;
FILE* fIn;
int num;
char code[2];
int one,two,three,sale,re,cost;
result pResult[6];
for(i=0;i6;i++)
{
strcpy(pResult[i].name,);
pResult[i].a=0;
pResult[i].b=0;
pResult[i].c=0;
pResult[i].d=0;
}
fIn=fopen(fname,r);
if(fIn==NULL)
{
printf(파일이 없습니다.\n);
return ;
}
while(fscanf(fIn,%d %s %d %d %d,&num,code,&one,&two,&three)==5) =이부분좀 설명부탁해요.
{ re = (int)(two*(three*0.9));
cost = one*three-re;
if(strcmp(code,S1)==0)
{
strcpy(pResult[0].name,등산화);
pResult[0].a += one;
p; pResult[0].b += one*three;
pResult[0].c += re;
pResult[0].d += cost;
}
if(strcmp(code,S2)==0)
{
strcpy(pResult[1].name,축구화);
pResult[1].a += one;
pResult[1].b += one*three;
pResult[1].c += re;
pResult[1].d += cost;
}
if(strcmp(code,S3)==0)
{
strcpy(pResult[5].name,농구화);
pResult[5].a += one;
pResult[5].b += one*three;
pResult[5].c += re;
pResult[5].d += cost;
}
}
printresult(pResult,6);
fclose(fIn);
}
void printresult(result*result, int SIZE)
{
int i, total=0;
printf(%-11s%-12s%-12s%-11s%-8s\n,신발명,판매수량,매츨액,반품액,순매출액);
for(i=0; i SIZE;i++)
{if(strcmp(result[i].name,)==0)
continue;
printf(%6s%12d%12d%13d%11d\n,result[i].name,result[i].a,result[i].b,result[i].c,result[i].d);
total += result[i].a;
}
printf(\n총 판매수량 : %d \n , total);
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
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 |
2695010 | C++의 STL은 왜 굳이 템플릿화 시켜서 라이브러리를 만드나요? (초보수준의 질문..) (2) | 엘보어 | 2025-05-16 |