Hi,
I have just done my Caesar's Cipher and it says that there is an error; In function 'int main()':[Error] name lookup of 'i' changed for ISO 'for' scoping [-fpermissive] [Note] (if you use '-fpermissive' G++ will accept your code), i got this error off this piece of code:
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
usingnamespace std;
int main()
{
char Letter, LetterBeingExamined, LetterBeingExaminedPlusOffset;
int Offset = 0;
int MessageLength = 0;
int ASCIICodeLetter[100];
Offset = 5;
cout << "Enter letter to be encrypted: ";
cin >> Letter;
MessageLength = 1;
cout << "\nThe letter you would like to Encrypt is: " <<Letter;
cout << "\n\nThe length of the Letter you want to Encrypt is " <<MessageLength << " byte(s) (including spaces).\n";
for (int i=0; i < MessageLength; i=i + 1)
{
Letter = LetterBeingExamined;
ASCIICodeLetter[i] = (int) LetterBeingExamined;
}
if ((int(LetterBeingExamined) >= 65) && (int(LetterBeingExamined)<= 122))
LetterBeingExaminedPlusOffset = (int) LetterBeingExamined + Offset;
cout << "Value of letter plus offset"<< int(LetterBeingExaminedPlusOffset);
if (LetterBeingExaminedPlusOffset > 90)
cout <<"\nValue of letter plus offset is greater than 90.";
LetterBeingExaminedPlusOffset = LetterBeingExaminedPlusOffset - 26;
LetterBeingExaminedPlusOffset = int(LetterBeingExamined);
cout <<"\nValue of Encrypted Letter after subracting 26 (if necessary) is " << int(LetterBeingExaminedPlusOffset);
ASCIICodeLetter[i] = LetterBeingExaminedPlusOffset;
ASCIICodeLetter[i] = LetterBeingExaminedPlusOffset;
cout << "\nEncrypted letter is " << LetterBeingExaminedPlusOffset << ".\n";
return 0;
}
On line 41 of this code, you use the variable i. That variable doesn't really exist at line 41. A variable named i exists inside the for loop, but not at line 41.