#include <stdio.h>
#include <stdlib.h>

typedef unsigned short word;

typedef struct headerInfo{
        int tsize;
        int count;
        int rsize;
}headinf;
        
typedef struct dataRec{
        long time;
        word oppid;
        word opppt;
        float before;
        float after;
        int ntrNum;
        int tapNum;
        int cbNum;
}drec;

int main(){
    
    headinf inf;
    drec rec;
    
    FILE *fp;
    
    fp=fopen(\"KJM1.txt\", \"w\");
    
    for(inf.count = 1; inf.count <= 100; inf.count++){
                     
                     rec.time = inf.count;
                     rec.oppid = inf.count;
                     rec.opppt = inf.count;
                     rec.before = inf.count;
                     rec.after = inf.count;
                     rec.ntrNum = inf.count;
                     rec.tapNum = inf.count;
                     rec.cbNum = inf.count;
                     
                     fwrite(&rec, sizeof(drec), 1, fp);
                     
                     inf.rsize = sizeof(rec);
                     inf.tsize = inf.count * inf.rsize;
                     
                     fwrite(&inf, sizeof(headinf), 1, fp);
    } 
    fclose(fp);
    
    system(\"pause\");
    return 0;
}
요런 소스를 짰어. rec에 inf.count로 초기화하고 inf.count는 for문 카운트 inf.rsize는 rec에 초기화된 데이터 사이즈
inf.tsize는 rec데이터사이즈와 횟수를 곱해서 총 사이즈를 구해서 inf데이터하고 rec데이터를 파일에 100번 쓰는거거든?
근데 생성된 파일 열어보면 쓰레기 값이 들어가네;;;; 당최 모르겠네... 디버깅을 해봤는데 rec에 inf.count값은 잘들어가드라고
for문도 잘돌아가서 값을 잘 넣어주고 int도 보니 사이즈값도 잘들어가는데.... fwrite부분이 조금 이상한거 같긴한데...
설명좀해줘 횽들 ㅠㅠ