"Write a function that takes a string (character pointer) as input and returns the string reversed. The function should reverse the string in place and return it as the return value of the function."
char *strrev(char *str) {
char* end = str;
char tmp = 0;
if(str) {
while(*end) {
end++;
}
--end;
while(end > str) {
tmp = *end;
*end-- = *str;
*str++ = tmp;
}
}
}
I am new to C++. I am facing difficulty with this. Can you please correct my code.