string ch[3] = { "abc" }; memset(ch,0,sizeof(ch)); cout << ch[0]<<endl; 字符串数组内存清空,输出为空; 但是! char ch1[3] = { 'a' }; memset(ch1, 0, sizeof(ch1)); cout << ch1[0] << endl; 当运行以上程序时,输出仍是a,为什么memset函数没有清空内存呢? 如何改正才能正确清空内存?
收起
在我的电脑上试了你的代码,输出为空,没有问题。
报告相同问题?