Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef enum{LOWERCASE,UPPERCASE,CAPITALIZED} StringMode;
- bool check(const char str[], StringMode sm)
- {
- switch (sm)
- {
- case LOWERCASE:
- for (int i=0; str[i]!='\0'; i++)
- if(str[i] >= 'A' && str[i]<='Z')
- return false;
- return true;
- case UPPERCASE:
- for(int i=0; str[i]!='\0'; i++)
- if(str[i] >='a' && str[i] <='z')
- return false;
- return true;
- case CAPITALIZED:
- {
- char temp[strlen(str)];
- strcpy(temp, str);
- char *p;
- p=strtok(temp, " ");
- while(p!=NULL)
- {
- if(p[0] >= 'a' && p[0] <= 'z')
- return false;
- for(int i=1; p[i]!='\0'; i++)
- if(p[i] >='A' && p[i] <= 'Z')
- return false;
- p = strtok(NULL, " ");
- }
- return true;
- }
- }
- }
- int main ()
- {
- printf("%d\n", check("SDsSDAD ASDSADSD ASDFSAFS", UPPERCASE));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement