How to get rid of compiler error-
deprecated conversion from string constant to ‘char*’
I got this compilation error while compiling the below code.void ABC(char *strng) {};
ABC("Hello World");
or
void ABC(char *strng){}; //This code may compile but the window will crash on execution
char *strng1="Hellow World";
ABC(strng1);
I find two solution for this...
1.
void ABC(char *strng){};
char strng1[] ="Hellow World";
ABC(strng1);
2. define const every where if the sting does no changes.
void ABC(const char *strng){};
const char *strng1 ="Hellow World";
ABC(strng1);
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
No comments:
Post a Comment