Still trying to play around with pointers, thought I would make this function. For some reason, it's not working and it's giving me this error.
I made it in a seperate file though.
Code:
int strlen(const char* string){
int n = 0;
for(;;)
{
if(string[n] == '\0') break;
n++;
}
return n;
}
void to_upper(char *string)
{
for(int i = 0, n = strlen(string); i < n; i++)
{
if( string[i] > 122 || string[i] < 97 ) continue;
(int) string[i] += 32;
}
}
now I'll call it in main
Code:
int main(){
char *name = "Aahmed";
to_upper(name);
printf("%s\n", name);
return 0;
}
giving me this error on compiling
error: lvalue required as left operand of assignment