Revert the given string and return the resulting string. Ex: input: "face" , result: "ecaf"
Anonymous
#include #include using namespace std; void revStr(string& str) { std::cout << str << endl; char* ep = &(str[str.size() - 1]); char* bp = &str[0]; for( ; ep != bp ; ep--, bp++) { char c = *ep; *ep = *bp; *bp = c; } } int main() { string str = "semih.kekul"; revStr(str); cout << str << endl; }
Check out your Company Bowl for anonymous work chats.