This capitalizes all of the words in a string.
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
char *capitalize(char *dest)
{
char *p=dest;
char last=0;
for(;*p;p++)
{
*p=tolower(*p);
if( isalpha((int)*p) && isspace(last)|| last ==0)
{
*p=toupper(*p);
}
last=*p;
}
return dest;
}
int main()
{
char test[32]={0x0};
char *p=NULL;
strcpy(test,"HELLO how are u?");
p=capitalize(test);
printf("%s\n",p);
return 0;
}
Sorry no strlen()...