未排序的双链表损坏中止核心转储

问题描述

#include<stdio.h>
     #include<stdlib.h>
     #include<string.h>
     #include <time.h>
     typedef char string [50];


     typedef struct adresse{ 

        int  zip_code;
        string city;
      } 
     adresse Fr[27381996];// I will upload data to this table from the file

     int main (){

       int i=-1,line_nb=1; 
       int j=1;
       double timing=0.0;//This is for calculating the timing 
       //These upcoming lines are for opening the file 
       FILE * France_adr;  
       France_adr=fopen("france.csv","r");

       char adr[300]; 

       for(line_nb=1;line_nb<10;line_nb++)
        {
          time_t begin= time(NULL);//Here I start the timing 

          while((!feof(France_adr))&& (i<line_nb))
            {
    
                fgets(adr,300,France_adr);
                char* s = strdup(adr);
                char* val = strsep(&s,","); /* This is because in the file 
                there are some data that I 
                don't want to use and they are separated with a comma*/
                while(val!=NULL)
                {
        
                    val=strsep(&s,");
                   // This is also to sort the data I want to get into my 
                   table
                   if(j==2 && i!=-1)
                     {
                       Fr[i].zip_code=atoi(val);
                       printf("%d | ",Fr[i].zip_code);
                      }
                   
                   j++;
                }

             i++;
             j=1;
             printf("\n");
           }
    fclose(France_adr);
    printf("\n\n");
 

    time_t end = time(NULL);
    duree += (double)(1000*(end-begin));

    //This section is for writing the timing and number of lines into a new 
    file
    FILE * donnee_t;
    donnee_t=fopen("Affichage_Donnee_Courbe.csv","a");
    fprintf(donnee_t,"\n %d,%f",i,duree);
    fclose(donnee_t);
    i=0;
   }
    return 0;
  }

我正在处理这个项目,我必须从文件上传大量数据。所以我要做的是在终端上显示这些数据行,看看显示它需要多少时间,并最终创建一条曲线,根据显示的行数显示时间如何演变(所以 我将显示的行数和显示在另一个文件 .CSV 中所花费的时间写下来。而且由于该文件有 2700 万行数据,我想为每次要显示多少行做一个循环,但是终端向我显示了这个错误。我希望我很好地解释了这个问题,我希望我能得到你的帮助。 enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)