删除char **的正确方法是什么 [英] What is the correct way to delete char**

查看:199
本文介绍了删除char **的正确方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个char **,基本上是一个字符串数组,我需要删除。

I have a char**, basically an array of strings, that I need to delete. What is the correct way of doing this to ensure all pointers are cleared up?

推荐答案

char** StringList ;
int nStrings ;
....
for (int i = 0 ; i < nStrings ; i++)
  delete[] StringList[i] ;
delete[] StringList ;

当然,如果您从

std::vector<std::string> Stringlist ;

然后就是

StringList.clear() ;

这篇关于删除char **的正确方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆