구조체 선언과 분리에 대한 질문입니다..급해요 좀 도와주세요...!
지니
구조체질문 요약 :구조체의 정의와 선언의 분리질문 내용 :
#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]; ===============여기 앞에struct 가 붙어야 하는거 아닌가요?책에서는 반드시
붙여주라고 배웠는데 학교 프린트 예제엔 안붙어 있어서 질문
드립니다.
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;
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);
}