-fpermissive

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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  #include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>

using namespace 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.
Hi,

The i on line 41 was not declared. The i on line 22 only lasts until line 26.

I can tell you compiled with c++98, advise setting to something later, like -std=c++11 or -std=c++14 whatever you have installed.

Also investigate the clang++ compiler: it's awesome, with nice error messages.

Good Luck !!
Topic archived. No new replies allowed.