I'm on Dev-C++ 4.9.9.2 default options, WinXP SP3, P4 w/ HT.
When I c-shift a value, and then back I get back distorted values. Using the standard _rotr() and _rotl.
/*somewhere in main()*/
str = "I'm a fairy! abc xyz ABC XYZ";
printf("\n%s\n", str.c_str());
for(i = 0; i < str.length(); i++)
{
str[i] = itoc(_rotr(ctoi(str[i]), 1));
}
printf("%s\n", str.c_str());
for(i = 0; i < str.length(); i++)
{
str[i] = itoc(_rotl(ctoi(str[i]), 1));
}
printf("%s\n", str.c_str());
/*till the end of main()*/
/*for clarity the ctoi, and itoc functions*/
inline int ctoi(char c)
{
int i = (int)c;
return(i);
}
inline char itoc(int i)
{
char c = (char)i;
return(c);
}
Am I just doing something wrong(like in the casting), or should I try another method?
Another problem might just be it's getting late, and should call it a night. lol