Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #define SIZE 20
- int main()
- {
- int i,j,inword = 0;
- char str[SIZE]="abc def ghk lmn opq";
- for(i=0;i<SIZE;i++)
- {
- if(!inword&&isalpha(str[i]))//first letter in word
- {
- str[i] = toupper(str[i]);
- inword=1;
- }
- else if(inword&&!(isalpha(str[i])))//first non-alpha after word
- {
- str[i-1] = toupper(str[i-1]);
- inword=0;
- }
- }
- for(i=0;i<SIZE;i++)
- printf("%c ",(str[i]));
- return 0;
- }
Add Comment
Please, Sign In to add comment