#include #include #include void SwapChars(char *string, int i, int j) { char temp; temp = string[i]; string[i] = string[j]; string[j] = temp; } void Rotate(char *string) { int i; for (i=0; i < strlen(string)-1; i++) { SwapChars(string, i, i+1); } } void IgPay(char *ingstray, char *string) { strcpy(ingstray, string); // "hello\0" -> "hello" cout << ingstray << endl; Rotate(ingstray); // "hello\0\0\0" -> "elloh" cout << ingstray << endl; int len = strlen(string); cout << ingstray << endl; ingstray[len] = 'a'; // "elloh" -> "elloha" cout << ingstray << endl; ingstray[len+1] = 'y'; // "helloa" -> "ellohay" cout << ingstray << endl; ingstray[len+2] = '\0'; // "helloay" -> "ellohay\0" cout << ingstray << endl; } int main() { char test[6]="buggy"; char esttay[8]; cout << test << endl; IgPay(esttay,test); cout << esttay << endl; }