0

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;

}

3
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by MastAvalons
0

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

Edited by NathanOliver: typo

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.