An array of pointers to strings is provided as the input. The task is to reverse each string stored in the input array of pointers. I\'ve made a function called reverseStrin
You are trying to change string literals.
String literals are usually not modifiable, and really should be declared as const
.
const char *s[] = {"abcde", "12345", "65gb"};
/* pointers to string literals */
If you want to make an array of modifiable strings, try this:
char s[][24] = {"abcde", "12345", "65gb"};
/* non-readonly array initialized from string literals */
The compiler will automatically determine you need 3 strings, but it can't determine how long each needs to be. I've made them 24 bytes long.