问题遇到的现象和发生背景
#include<iostream>
using namespace std;
int main()
{
char ostr[100]; char destr[100];
cout << "请输入一个不含空格的字符串:" << endl;
cin >> ostr;
cout << "请输入要删除的字符:" << endl;
cin >> destr;
for (int i = 0; ostr[i] != '\0'; i++)
{
for (int j = 0; destr[j] != '\0'; j++)
{
if (ostr[i] == destr[j])
{
for (int k = i; ostr[k] != '\0'; k++)
{
ostr[k] = ostr[k + 1];
}
}
}
}
cout << "删除后的字符串为:" << ostr;
return 0;
}
运行结果及报错内容