편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2021.06.07

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


        #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는 건드리면 안됩니다.

  • 프로필 알 수 없는 사용자님의 편집
    날짜2021.06.06

    c언어 txt퍄일 읽어와서 저장


    #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는 건드리면 안됩니다 ㅠㅠ