c언어 txt파일을 읽어와서 저장

조회수 633회
    #include "dheap.h"
        dheap* create(dheap* h, char* file, int d) {
        int i;
        FILE* pfile;
        pfile = fopen(file, "r");
        fscanf(pfile, "%d", &h->current_size);

    for (i = 0; i < h->current_size; i++) {

            fscanf(pfile, "%d", &h->heap_array[i]);

        }
        fclose(pfile);

        for (i = 0; i < h->current_size; i++) {
                printf("%d", h->heap_array[i]);
        }
            }
      void main() 
        ``{
             dheap* heap = NULL;
            heap = create(heap, "h1.txt", 3);
            }
  • dheap.h

    
        #include <stdio.h>
        #include <stdlib.h>
        #include <string.h>
        #include <math.h>
    
        #ifndef __DHEAP_H__
        #define __DHEAP_H__
        #define _CRT_SECURE_NO_WARNINGS
        #define  MAX_SIZE 30
    
        typedef struct dheap
        {
            int d; // maximum degree of heap
            int current_size; // current size of the heap
            int heap_array[MAX_SIZE]; // MAX_SIZE is defined in dheap.h
            int position_array[MAX_SIZE]; // stores the position where the values 0…MAX-1 are stored in                     heap_array
        }dheap;
    

    txt파일을 읽어와서 저장된 값들을 출력하려 하는데 오류는 안나는데 저장된 값들이 출력이 안됩니다. void main는 건드리면 안됩니다.

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)