Incorrect conversion from 'const char * to' char * [-fpermissive]

int :: cadena calculatelenght(const cadena& a, const char* cad) { cadena c; int lenght = 0; char* punt; punt = cad; while(*punt){ lenght++; punt++; } return lenght; } 

I have this problem, I want to calculate the length of the C string without using functions like strlen , in other methods of my cadena class I can, because it is not const char *, but now I do not know what to do.

+7
source share
2 answers

You can declare punt correct type:

 const char * punt = cad; 
+9
source

You need:

 const char* punt; punt = cad; 
+4
source

All Articles