I'm running into a problem here with segmentation faults.
Here is the code:
string CipherMessage::VigDecipher(string key)
{
int keyValue;
int charValue;
string textInit = m_text;
// Initializes an array containing the alphabet. A=index 0, B=index 1, etc
string alphabet[26] = "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O"\
"P","Q","R","S","T","U","V","W","X","Y","Z"};
// keyValues contains the values of each term of the multi-character key.
int keyValues[6];
// Enters the keyValues into the array.
for (int i=0; i<key.length(); i++){
for (int j=0; i<=25; j++){
if (key[i] == ALPHABET[j])
keyValues[i] = j;
}
}
return m_text_new;
}
It just gives me the segmentation fault.
I'm going to guess that this line is the problem:
for (int j=0; i<=25; j++){
Note that the character i
is not the character j
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.