S
SysSpider
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 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) //Here starts the problem
{
case charToInt(cryptMsg) < charToInt(key): //Error
printf("%d", charToInt(cryptMsg) + 10 -
charToInt(key));
break;
case charToInt(cryptMsg) >= charToInt(key): //Error
printf("%d", charToInt(cryptMsg) -
charToInt(key));
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 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) //Here starts the problem
{
case charToInt(cryptMsg) < charToInt(key): //Error
printf("%d", charToInt(cryptMsg) + 10 -
charToInt(key));
break;
case charToInt(cryptMsg) >= charToInt(key): //Error
printf("%d", charToInt(cryptMsg) -
charToInt(key));
break;
default:
printf("\nError!\n");
break;
}
}
}
--End of source--