deprecated conversion from string constant to 'char*'

Hi all

I am working with strings and i cant figure out why the following

warning appears at time of build.


warning: deprecated conversion from string constant to 'char*'

It appears for the line


char *myName = "Apple.txt";

Is there anyone who can help me?

Help is welcome.

Thanks in advance.

Mac mini, Mac OS X (10.6.4)

Posted on Mar 13, 2013 12:31 AM

Reply
8 replies

Mar 13, 2013 6:53 AM in response to Dhiraj Bhor

The warning you are getting is because a string constant is now assumed by the compiler to be invariable and handled differently that a string pointed to by a char * which by it's very nature is changeable.


However if I create code like that in Xcode or in a plain .c file and compile it I do not see the warning so how are you creating and compiling the code?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

deprecated conversion from string constant to 'char*'

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.