The qualifier const only indicates that the variable cannot be changed.
So the code below means that the data pointed by the file pointer is not changeable:
void Processa(const char * file)
{
....
}
The compiler is in charge of generating an error alert if the code in the routine tries to change the content pointed by the pointer.
Note that const char *p or char const *p has the same meaning, that is, the pointed data are not modifiable. But char * const p means the pointer is constant and cannot be modified.
So it should be no problem, you pass a string variable without const qualifier to a routine like the one shown in your question.
[EDIT]
Rereading your question I realized that your problem is that the parameter you are trying to pass to the routine is generating the error when compiling, correct?
If yes, test use casting
to tailor the parameter to what is required by the call routine, for example:
char *p = Mix_LoadMUS ( (const char *) file )
Is this string the string type of C++, or is it a string type of another library? If it is the default C++ type, I think s.c_str() returns a standard C-compatible const char * .
– epx
The "const char *file" specification is only to ensure that the function will not modify the content pointed by the file pointer.
– user4552
I am using only C, this string comes from a function written with the GTK library, this function is a (File_chooser) screen where the user chooses the file he wants to open. I can view the contents of the string by printing it into a file (fprintf). The problem is that when I try to pass this string to the other function, the program closes.
– Lucas
It’s kind of like Gstring?
– Lucas Lima
Put the code snippet please.
– ademar111190