C Pointers with Strcat

I'm trying to strcat char *. However, I've noticed an issue. struct d{ struct d* up //parent char *path //path to d char *name //path + breadth = name } for(j=0; jup=cur_parent; breath_path->path=cur_parent->up->name; breadth_name=strcat(breadth->path, buffer); printf("name: %s\n", breadth_p->name); free(breadth_p); } so say I pass the cur_parent name and path as root and b as 3. the following prints out root/0 root/0/1 root/0/1/2 I'm assuming that I didn't free the breadth_p correctly so it's concatenating the previous names. the results I'm expecting is root/0 root/1 root/2 Can anyone help me figure out why this is happening?

以上就是C Pointers with Strcat的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准