Loading

基本段错误

struct dir_copy path ;
sprintf(path.srcdir_path,"%s/%s",src_path,dir->d_name);
sprintf(path.destdir_path,"%s/%s",root_dir,path.srcdir_path);
printf("file = %s\n",path.srcdir_path); 
printf("file = %s\n",path.destdir_path);



struct dir_copy* path = (struct dir_copy*)malloc(sizeof(struct dir_copy));
    //不能用struct dir_copy* path;
    //否则会报段错误
sprintf(path->srcdir_path,"%s/%s",src_path,dir->d_name);
sprintf(path->destdir_path,"%s/%s",root_dir,path->srcdir_path);
printf("file = %s\n",path->srcdir_path); 
printf("file = %s\n",path->destdir_path);    

 

posted @ 2019-04-25 20:46  砚车干  阅读(205)  评论(0编辑  收藏  举报