I know you will say its a duplpicate but belive me i read alot of articles about this but i still cant understand what is the diffrence so im giving two examples.
1.
int strlen(const char* string)
{
int i = 0;
while (string[i] != '\0')
{
++i;
}
return i;
}
2.
int strlen(char* string)
{
int i = 0;
while (string[i] != '\0')
{
++i;
}
return i;
}
Main:
int main()
{
char str[] = "Hello";
cout << strlen(str) << endl;
}
The second will work and wont get errors while the first wont.