The title basically sums it up. I first compared if the characters of the string are in between a and z. then, if they are, reduced their ascii by 32, hence obtaining their capitals.
But if the function encounters a space in the string, it modifies the argument string such that all the rest after the space are not capitalized and added back in the string.
Eg the desired output was WANNA GO but it outputs WANNA.
#include <stdio.h>
void capitalizer(char arr[]){
for(int i=0; arr[i]!=''; i++)
{
if('a' < arr[i] < 'z'){
arr[i] -= 32;
}
}
}
int main() {
char name[] = "wanna go";
puts(name);
capitalizer(name);
puts(name);
return 0;
}
i changed the comparing condition to if('a' <= arr[i] && arr[i] <= 'z')
and it worked so i guess thats where the issue is.
2