I am getting this error with when I compile. I have to turn this assignment in in a few hours. Here is the code:

error message(s)

untitled.cpp:34: error: invalid types ‘int[int]’ for array subscript
untitled.cpp:36: error: invalid types ‘int[int]’ for array subscript

// A basic Casear Cipher Encrytion Device.

include <iostream>
include <iomanip>

using namespace std;

define RINGLEN 62
// NUM OF CHARS IN ALLOWED CHARACTER SET.

int main ()
{
int i=0; // index variables
int j=0;
char ring[RINGLEN+1]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
int key = 4;
const int size = 1000;
char word[size+1];

cout << "Please insert the message you would like to encrypt: ";
cin >> word;

for (int i=0;i<size;i++)
{
    if ((word[i] >='A' && word[i] <='Z') || (word[i]>='a'&&word[i]<='z') ||(word[i]>='0'&&word[i]<='9'))
    {
        int ring = word[i] + key;


        for (int j=0; j<=RINGLEN;j++) 
        {
            if (word[i] == ring[j])
            {
                cout << ring[(j+key) % RINGLEN];
                break;
            }
        }  
    }


    else 
    {
        cout << word[i];

    }
}
return 0;

}

Recommended Answers

All 3 Replies

The problem you are having is ring is declared as an int but you are trying to use it as an int array.

thanks.resolved the problem a few hours ago.

"int[int]" - may be array of integer?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.