#include <stdio.h>
#include <string.h>
#define MAX_LENGTH 100
void reverse(char *userString);
int main() {
char userWord[MAX_LENGTH];
printf("Enter a word: \n");
fgets(userWord, sizeof(userWord), stdin);
printf("Original word: %s", userWord);
reverse(userWord);
printf("Reversed word: %s", userWord);
return 0;
}
void reverse(char *userString){
int length = strlen(userString);
for(int i = 0; i < length / 2; i++) {
char temp = userString[i];
userString[i] = userString[length - 1 - i];
userString[length - 1 - i] = temp;
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: