deprecated conversion from string constant to 'char*'
As is my wont, I'm going to provide a bit of background technical information into the whys and wherefores of this this error.

I'm going to inspect four different ways of initializing C strings and see what the differences between them are.  These are the four ways in question:

char *text = "This is some text";
char text[] = "This is some text";
const char *text = "This is some text";
const char text[] = "This is some text";


Now for this I am going to want to change the third letter "i" into an "o" to make it "Thos is some text".  That could, in all cases (you would think), be achieved by:

text[2] = 'o';


Now let's look at what each way of declaring the string does and how that text[2] = 'o'; statement would affect things.

First the most commonly seen way: char *text = "This is some text";.  What does this literally mean?  Well, in C, it literally means "Create a variable called text which is a read-write pointer to this string literal which is held in read-only (code) space.".  If you have the option -Wwrite-strings turned on then you get a warning as seen in the question above.

Basically that means "Warning: You have tried to make a variable that is read-write point to an area you can't write to".  If you try and then set the third character to "o" you would in fact be trying to write to a read-only area and things won't be nice.  On a traditional PC with Linux that results in:


  Segmentation Fault


Now the second one: char text[] = "This is some text";.  Literally, in C, that means "Create an array of type "char" and initialize it with the data "This is some text\0". The size of the array will be big enough to store the data".  So that actually allocates RAM and copies the value "This is some text\0" into it at runtime.  No warnings, no errors, perfectly valid.  And the right way to do it if you want to be able to edit the data.  Let's try running the command text[2] = 'o':


  Thos is some text


It worked, perfectly.  Good.

Now the third way: const char *text = "This is some text";.  Again the literal meaning: "Create a variable called "text" that is a read only pointer to this data in read only memory.".  Note that both the pointer and the data are now read-only.  No errors, no warnings. What happens if we try and run our test command?  Well, we can't.  The compiler is now intelligent and knows that we are trying to do something bad:


  error: assignment of read-only location ‘*(text + 2u)’


It won't even compile.  Trying to write to read-only memory is now protected because we have told the compiler that our pointer is to read-only memory.  Of course, it doesn't have to be pointing to read-only memory, but if you point it to read-write memory (RAM) that memory will still be protected from being written to by the compiler.

Finally the last form: const char text[] = "This is some text";.  Again, like before with [] it allocates an array in RAM and copies the data into it.  However, now this is a read-only array.  You can't write to it because the pointer to it is tagged as const.  Attempting to write to it results in:


  error: assignment of read-only location ‘*(text + 2u)’


So, a quick summary of where we are:

This form is completely invalid and should be avoided at all costs.  It opens the door to all sorts of bad things happening:

char *text = "This is some text";


This form is the right form if you are wanting to make the data editable:

char text[] = "This is some text";


This form is the right form if you want strings that won't be edited:

const char *text = "This is some text";


This form seems wasteful of RAM but it does have its uses.  Best forget it for now though.

const char text[] = "This is some text";