So, im writing a c++ program and i have it all done encept for some reason i cannot get the idea behind shifting a string down.
so i was wondering how you code to get
abc...yz to become
bcd...za?
well i guess what i mean is then how would the programming work for it then. if you take the string from the user and get its size with something like input.size then you would have a cutoff for the letters but after you have this and you can operate on them, the way by which you shift the words is tricky. if i shift them by making a=0, b=1 and so forth then a shift over will make something become a letter that is not a number.
so that is what i mean by the idea of it. how to shift without the loss of that number and how to place it at the beginning. so that a user can input a shift value of lets say 6, and type xyz to get cde.
>>5
You mean you're using the word ``shift'' to mean a Caesar cipher, and not something like bitshifting?
You're even dumber than I thought.
Name:
Anonymous2010-09-01 23:32
...thanks
now accepting that i am ignorant and forever a tard i am going to ask if i can get some clarity on the subject and yes it is a Caesar cipher i am trying to program for.
the thing that is messing with me is not so much the action of the cipher as it is that the assignment i have is making me take in a string to deal with it instead of cin.get or getline or an array. which i think would make this much easier.
...im not asking about the addition or the subtraction im asking how you take a string, and take a shift value and given a set of letters wrap them once they exceed the end letter in the set.
void shift_str(char *str) {
char a = str[0];
int l=strlen(str);
memmove(str,str+1,l);
str[l]=a;
}
Name:
Anonymous2010-09-02 4:24
>>17
It's funny, I wrote almost exactly that same code about eight hours ago, memmove and all. I was about to post when I re-read his question and realized that he doesn't just want to move the first character to the end; he wants a Caesar cypher.
So I felt stupid for a while. But at least I had the foresight not to hit reply!
Name:
Anonymous2010-09-02 5:04
>>17,18: to prevent you two morons from feeling too good about yourselves: rotate(s.begin(), s.begin() + 1, s.end());
This endless reinvention of the same square wheel. This arrogant ignorance of the fucking standard library that does the goddamn thing right. C programmers are scum, unworthy of the gift of life.
>>25
Would be funnier if it actually did return the "YHBT" so that the guy using the function would scratch his head for a second... before the reality set in.