Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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
Question marked as Best reply

Posted on Mar 13, 2013 12:40 AM

Any reason why you aren't using NSString in place of char?


char *myName = "Apple.txt";


NSString *myName = @"Apple.txt";

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?

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 ID.