I need an efficient implementation of a function in C that would be given a char[] and it will remove all uppercase characters from it returning everything left.
e.g. if given HELLOmy_MANname_HOWis_AREjohn_YOU__
it should return my_name_is_john__
this is not a HW too easy to be one, but its 2am in my timezone and I think this would be a solution to a problem im facing in my code now!
any help is welcome! cheers!=)
maybe this?
i = j = 0;
while (s[i] != '\0') {
if (!isupper(s[i])
t[j++] = s[i];
i++;
}
t[j] = '\0';
How about an algorithm some pseudo-code?
initialize a rewrite pointer to the beginning of the string
for each character in the input string that isn't nul:
if character is not an uppercase letter:
add the character to rewrite pointer
increment rewrite pointer
add nul terminator to rewrite pointer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With