I'm trying to understand why the declaration method of my strings does and doesn't allow me to modify them, let me explain more.
If I declare an array of strings like so: char *Strs[] = {"Str1", "Str2", "Str3"}; I can read the strings and print them to screen using printf etc. I can't however modify them how I'd expect to, for example: Strs[0][0] = 'A' does nothing to the string once I print it (I will paste my test code below...)
If however, I declare the array: char Strs[3][5] = {"Str1", "Str2", "Str3"}; I can read and modify the strings using the array method.
Why does my method of modification not work in the first instance?
int main(int argc, char **argv)
{
/* Doesn't work
char *Strs[] = {"Str1", "Str2", "Str3"};
printf("Premod: %s\n", Strs[0]);
Strs[0][0] = 'A';
printf("Postmod: %s\n", Strs[0]);
*/
//Works
char Strs[3][5] = {"Str1", "Str2", "Str3"};
printf("Premod: %s\n", Strs[0]);
Strs[0][0] = 'A';
printf("Postmod: %s\n", Strs[0]);
return 0;
}