>say i want to print....
>" c programming is fun! "
>and i want it to capitolize this way...
>"C programming IS fun"
I think I follow you now.
You could modify your function so that it specifies a start and range area of the string you want to captilise. Something like:
Code:
void convertToUppercase( char *sPtr, int start, int cnt )
{
int pos = start;
while ( pos < start + cnt )
{
if ( islower( sPtr[pos] ) )
sPtr[pos] = toupper( sPtr[pos] ); // convert to uppercase
pos++;
}
}
I've haven't compiled this, so there maybe one or two glitches, but the gist of it should be there. I've also use a slight variation of for de-referencing the string pointer on a per char basis because I find this easier, but it should make no difference overall.
Now if your string was:
"c programming is fun!"
calling:
Code:
convertToUpperCase(strPtr, 14, 2);
should change to strPtr to
"c programming IS fun!"
also calling convertToUpperCase(strPtr, 0, 1);
should convert your start character, so that it becomes
"C programming IS fun!"