-

2011年8月4日星期四

Need help shifting pointers in c++?

-I'm supposed to make a 12 character long word, store it in a char*, and shift it by a user inserted integer.



For example,



Hello World

3

rldHello Wo



i'm not exactly sure how to do this. So far, i've got:



#include <iostream>

#include <string>

using namespace std;



int main ()

{

int h;

char* string;



cout << "\nEnter a 12 letter word: ";

cin >> string;



cout << "\nEnter an integer: ";

cin >> h;



cout << "\nYour shifted Word is" << string << endl << endl;



system("pause");

return 0;



I don't know how to first create a char* if you are dealing with 2 words as it only took the first word when i tried it.



Also, i don't know how to control the shift of the letters



I do not expect you to write this for me, but some guidance in the correct direction would be appreciated



Thank you

没有评论:

发表评论