Hi again,
This is my problem: when i try to compile the code that contains the
function below, i get this:
--
gcc:21: error: case label does not reduce to an integer constant
gcc:24: error: case label does not reduce to an integer constant
--
Now, I (think that I) understand the error, but cryptMsg[i] surely
doesn't look like a constant to me...
Thanks for help,
SysSpider
P.S.: btw, for those interested, I'm implementing the "one time pad"
cryptography system, although that isn't important to the problem...
--Source code--
void decryptMsg(int sizeMsg) {
int i;
char cryptMsg[sizeMsg], key[sizeMsg];
printf("\nEnter the encrypted message (no spaces): ");
scanf("%s", cryptMsg);
printf("Enter the used key (no spaces): ");
scanf("%s", key);
printf("\nThe message is:\n");
for(i = 0; i < sizeMsg; i++)
{
if(i%2 == 0 && i != 0) printf(" ");
switch(cryptMsg[i]) //Here starts the problem
{
case charToInt(crypt Msg[i]) < charToInt(key[i]): //Error
printf("%d", charToInt(crypt Msg[i]) + 10 -
charToInt(key[i]));
break;
case charToInt(crypt Msg[i]) >= charToInt(key[i]): //Error
printf("%d", charToInt(crypt Msg[i]) -
charToInt(key[i]));
break;
default:
printf("\nError !\n");
break;
}
}
}
--End of source--
This is my problem: when i try to compile the code that contains the
function below, i get this:
--
gcc:21: error: case label does not reduce to an integer constant
gcc:24: error: case label does not reduce to an integer constant
--
Now, I (think that I) understand the error, but cryptMsg[i] surely
doesn't look like a constant to me...
Thanks for help,
SysSpider
P.S.: btw, for those interested, I'm implementing the "one time pad"
cryptography system, although that isn't important to the problem...
--Source code--
void decryptMsg(int sizeMsg) {
int i;
char cryptMsg[sizeMsg], key[sizeMsg];
printf("\nEnter the encrypted message (no spaces): ");
scanf("%s", cryptMsg);
printf("Enter the used key (no spaces): ");
scanf("%s", key);
printf("\nThe message is:\n");
for(i = 0; i < sizeMsg; i++)
{
if(i%2 == 0 && i != 0) printf(" ");
switch(cryptMsg[i]) //Here starts the problem
{
case charToInt(crypt Msg[i]) < charToInt(key[i]): //Error
printf("%d", charToInt(crypt Msg[i]) + 10 -
charToInt(key[i]));
break;
case charToInt(crypt Msg[i]) >= charToInt(key[i]): //Error
printf("%d", charToInt(crypt Msg[i]) -
charToInt(key[i]));
break;
default:
printf("\nError !\n");
break;
}
}
}
--End of source--
Comment