Originally Posted by
aijazbaig1
Hello,
heres the code:
Code:
...
void set2caps(char *str_hld)
{
unsigned int chr_cnt = 0;
char temp;
while(str_hld[chr_cnt]) {
if (!isupper(str_hld[chr_cnt]))
temp = toupper(str_hld[chr_cnt]);
str_hld[chr_cnt] = temp;
chr_cnt++;
}
}
Actually, there's a bug in this function. It should be changed as follows:
Code:
void set2caps(char *str_hld)
{
unsigned int chr_cnt = 0;
char temp;
while(str_hld[chr_cnt])
{
if (!isupper(str_hld[chr_cnt]))
{
temp = toupper(str_hld[chr_cnt]);
str_hld[chr_cnt] = temp;
}
chr_cnt++;
}
}
Otherwise, all letters that were previously capitalized are either ignored (temp is not initialized) or set to the previous uncapitalized letter.