+-

基本上应该做的是:
1)获取字符串并找到其长度
2)遍历key中的所有元素并将所有唯一成员放入start(playfair密码)
Table::Table(string key) {
int i;
for(i = 0; i < key.length(); i++) {
if(start.find(key[i]) == string::npos) { //start is empty string
start[start.length()] = key[i]; // this line gives error
}
}
}
错误:
最佳答案
因为有效索引的范围从0到长度 – 包括1.如果要在字符串中添加char,请使用push_back
start.push_back(key[i]); //this will increase the length by 1
点击查看更多相关文章
转载注明原文:C字符串操作,字符串下标超出范围 - 乐贴网