Q. WAPC to read a string into an aaray and capitalize the first character of every word in the input.
Solution I tried
#include<stdio.h>
int main(void)
{
char string[50];
char *ptr;
printf("Enter string\n");
fgets(string,sizeof string,stdin);
printf("string= \"%s\"\n",string);
for(ptr=string;string!='\0';ptr++)
{
if(*ptr==' ')
{
ptr++;
*ptr=*ptr-32;
}
}
printf("The new string is %s",string);
return 0;
}
What have I done wrong?????