基本段错误
作者:互联网
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);
标签:基本,struct,错误,printf,srcdir,path,copy,dir 来源: https://www.cnblogs.com/huang-y-x/p/10770870.html