For my driver I have to reverse the strings in a string literal by means of a class called ReverseString. I will show you guys my function below that is supposed to reverse my string. I will also post my test for the string. My output is:
ahsuruP
ahsuruP
ahsuruP
and I am pretty sure that is not the correct output. Why doesn't my function work? Thanks for the help
Code:ReverseString ReverseString::operator ~() { int k = 0; char *temp = buf; for(int i = stringlength-1; i>=(stringlength/2); i--) { swap(temp[k], temp[i]); k++; } return temp; } void test19() { system("cls"); cout << "19. Testing: ReverseString class." << endl << endl; csis << "19. Testing: ReverseString class." << endl << endl; ReverseString s19("Purusha"); ReverseString t19; s19.setName("s19"); t19.setName("t19"); t19 = ~s19; s19.print(); t19.print(); ReverseString u19(~~s19); u19.setName("u19"); u19.print(); wait(); }



LinkBack URL
About LinkBacks



