#include <stdio.h>
#define NUM 101
int main()
{
int i,j=0;
int bin[45]={};
int rotto[NUM][6]={};
int stat[NUM][6]={};
FILE*fw;
FILE*fr;
FILE*fp;
fw=fopen("lotto_stat.txt","w");
fr=fopen("lotto.txt","r");
for(i=0;i<NUM;i++){
for(j=0;j<6;j++){
fscanf(fr,"%d", &rotto[i][j]);
}
}
for(i=0;i<NUM;i++)
{
for(j=0;j<6;j++)
{
if (&rotto[i][j])
{
stat[&rotto[i][j]] = stat[&rotto[i][j]]++;
}
}
}
for(i=1; i<=45;i++)
{
for(j=0;j<6;j++)
{
printf("%d :%d",i,stat[i][j]);
printf("\n");
}
}
for(i=1; i<=45; i++)
{
fprintf(fp,"- ",stat[i]);
}
fprintf(fp,"\n");
fclose(fp);
fclose(fr);
fclose(fw);
return 0;
}
lotto.txt파일을 불러와서 배열마다 숫자를 읽어서 어떤숫자가 몇번나왔는지 세는 c언어프로그래밍중인데
fopen, fopen, fscanf 부분은 경고고
stat[&rotto[i][j]] = stat[&rotto[i][j]]++;이부분은 뭔짓을해도 프로그램이안돌아가는데.. 방법이없을까요
근데 &값을안넣으면 ++를 넣을수가없어서요..
rotto[i][j]의 번지가 0xABCD라고 치면 저 대입문은 stat[0xABCD] = stat[0xABCD]++라고 생각하심 왜 잘못됫는지 아실듯