An important point that is deduced, but not specified explicitly:
Based on your question, I assume that you are fairly new to C programming, so I would like to explain a little more about your situation. Forgive me if I am wrong; C can be difficult to learn mainly due to a subtle misunderstanding in the underlying mechanisms, so I like to make everything as simple as possible.
As you know, when you write out your C program, the compiler pre-creates everything for you based on the syntax. When you declare a variable anywhere in your code, for example:
int x = 0;
The compiler reads this line of text and says to itself: OK, I need to replace all occurrences in the current area of ββcode x permanent link to the area of ββmemory that I allocated for storing an integer.
When your program is running, this line leads to a new action: I need to set the memory area that x refers to int value 0 .
Note the slight difference here: the memory location where the breakpoint x is located is constant (and cannot be changed). However, the value that x indicates can be changed. You do this in your code through assignment, for example. x = 15; . Also note that one line of code actually constitutes two separate commands to the compiler.
If you have an operator like:
char *name = "Tom";
The compiler process looks like this: OK, I need to replace all occurrences in the current area of ββthe name code with a permanent link to the memory area that I allocated to hold the value of the char pointer. And he does it.
But there is that second step, which boils down to the following: I need to create a constant array of characters that contains the values ββ"T", "o", "m" and NULL . Then I need to replace the part of the code where "Tom" indicates the memory address of this constant string.
When your program is running, the last step occurs: setting the pointer to char (not constant) to the memory address of the automatically generated line (which is constant).
So char * not read-only. Only const char * is read-only. But your problem in this case is not that char * read-only, it means that your pointer refers to read-only memory areas.
I give all this because understanding this problem is an obstacle between the fact that you look at the definition of this function from the library and understand the problem yourself or ask us a question. And I somewhat simplified some details in the hope of making the problem more understandable.
Hope this was helpful .;)