user16973
user16973

Reputation: 113

Why does TTF_RenderText_Blended need a const char?

I am trying to use the result of a function to feed a string to TTF_RenderText_Blended. this would mean it needs to be a variable,however. looking at the declaration it insists that the argument must be a const char.

Upvotes: 0

Views: 173

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409176

I assume you mean const char *, i.e. a pointer to a constant string (that's what the reference manual says), meaning the function can not modify the string. Which is precisely the meaning of using const here, to tell the compiler (and the user of the API) that the function will not modify the string. This allows you to pass a string literal safely to the function, for other strings just pass it normally and it will work just the same.

Upvotes: 4

Related Questions