Viết chương trình C để đảo ngược chuỗi

Code tham khảo của chương trình C:

#include <stdio.h>

void reverseString(char* str) {
char* end = str;
char temp;
// find the end of the string
while (*end) {
end++;
}
end--; // back up one character from the null terminator

// swap the characters from the start and end, moving toward each other
while (str < end) {
temp = *str;
*str = *end;
*end = temp;
str++;
end--;
}
}

int main() {
char str[] = "Hello, World!";
printf("Original string: %s\n", str);
reverseString(str);
printf("Reversed string: %s\n", str);
return 0;
}