Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Warning: assigning const char* to char*
This is a very simple question but I couldn't find it in your FAQ.
I'm using VC++ and compiling a C program, using the /TC flag.
I've got a function for comparing two strings
int strspcmp(const char * s1, const char * s2)
char* pS1 = s1;
char* pS2 = s2;
As you can see, I assign the two const ptrs to some non-const ptrs to do some ptr arithmetic,
like incrementing the ptrs to compare the strings.
But I'm getting warning C4090 complaining about the assignment.
I thought I was doing the standard thing for ptr arithmetic. What am I doing wrong?
How do I get rid of the warning?
0 · ·