|
|
|
#1 (permalink) | |||||||||||||
|
Folding Fanatic
![]() |
I know you guys are probably getting sick of my programming questions, but you guys are a lot more helpful than my TA has ever been, so here it goes. I need to develop a reverse Caesar cipher (A=D. Z=C, etc) function as part of a larger program. I'm not sure what I've done wrong :
Code:
//Function 1 - undoes the Caesar Cipher
char revCaesar(char ch)
{
if(isupper(ch))
{
if(ch <= D and ch >= Z)
{
int ch;
ch = ch - 3;
return ch;
}
else
switch(ch)
{
case 'A':
ch = "X";
break;
case 'B':
ch = "Y";
break;
case 'C':
ch = "Z";
break;
}
return ch;
}
else
{
if(ch <= d or ch >= z)
{
int ch;
ch = ch - 3;
return ch;
}
else
char s;
switch(ch)
{
case 'a':
s = "x";
break;
case 'b':
s = "y";
break;
case 'c':
s = "z";
break;
}
return ch;
}
}
Last edited by tofunater : 10-15-09 at 09:33 PM |
|||||||||||||
|
|
|
|
|
#3 (permalink) | |||||||||||||
|
Folding Fanatic
![]() |
Seriously? My assignment notes must be wrong, dammit. Fixed it now. Would you notate the syntax errors for me, I really am lost as to what is wrong.
|
|||||||||||||
|
|
|
|
|
#4 (permalink) | |
|
Case Modder
![]() |
Quote:
Code:
//Function 1 - undoes the Caesar Cipher
char revCaesar(char ch)
{
if(isupper(ch))
{
if(ch <= D and ch >= Z) // D and Z should be surrounded by single quotes
{
int ch;
ch = ch - 3;
return ch;
}
else
switch(ch)
{
case 'A':
ch = "X"; // use single quotes
break;
case 'B':
ch = "Y";
break;
case 'C':
ch = "Z";
break;
}
return ch;
}
else
{
if(ch <= d or ch >= z)
{
int ch;
ch = ch - 3;
return ch;
}
else // missing {
char s;
switch(ch)
{
case 'a':
s = "x"; // use single quotes
break;
case 'b':
s = "y";
break;
case 'c':
s = "z";
break;
}
return ch; // return s, no?
// missing }
}
}
__________________
Rich Custom Wooden Case Builder
|
|
|
|
|
|
|
#5 (permalink) | |||||||||||||
|
Folding Fanatic
![]() |
thanks for that spotswood, and... that did it. Once again, my class notes failed me. The switch statements were modeled exactly off of what I was given
|
|||||||||||||
|
|
|
|
|
#6 (permalink) | ||||||||||||||
|
Security Sleuth
![]() |
Why is ch an int? Just use a char and the correct single quotes.
You need to define or quote D / Z. Code:
if(ch <= d or ch >= z)
{
int ch;
ch = ch - 3;
return ch;
}
__________________
Quote:
Proud Member of the Linux Gaming CommunityI am your friend.
|
||||||||||||||
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|