#include <stdio.h>
#include <string.h>
void reverse(char * str[]) {
int i;
int reverse = sizeof(str);
for(i=0;i<=sizeof(str);i++){
*str[i]=*str[reverse];
reverse--;
}
}
main() {
char *word;
printf("Enter a word please=>");
scanf("%s",word);
reverse(word);
printf("%s",word);
}
I am trying to get a string input and pass it to reverse()
function to reverse the word entered i.e ("abcd" -> "dcba")
, however i am having some difficulty using pointers.
I am not able to change the values held by the char *word
in the memory.