Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void main() {
- // vars
- char ch1[50],ch2[50],ch3[50];
- // getting chars
- puts("gimme ch1 \n");
- gets(ch1);
- puts("gimme ch2 \n");
- gets(ch2);
- // ops
- printf("ch1 is equal to \" %s \" \n",ch1);
- printf("ch2 is equal to \" %s \" \n",ch2);
- // comp
- int comp;
- comp = strcmp(ch1,ch2);
- switch(comp) {
- case 0: printf("ch1 = ch2 \n"); break;
- case 1: printf("ch1 > ch2 \n"); break;
- case -1: printf("ch1 < ch2 \n"); break;
- default: printf("WTF !! \n"); break;
- }
- // concatination
- strcpy(ch3,ch1);
- strcat(ch3,ch2);
- printf("ch1 + ch2 = '%s' \n", ch3);
- // num values
- printf(" the numeric values of ch1 and 2 are %d and %d \n",atoi(ch1),atoi(ch2));
- // identification
- printf(" ch1 is upper ? %d \n",isupper(ch1[0]));
- printf(" ch2 is upper ? %d \n",isupper(ch2[0]));
- printf(" ch1 is lower ? %d \n",islower(ch1[0]));
- printf(" ch2 is lower ? %d \n",islower(ch2[0]));
- printf(" ch1 is decimal ? %d \n",isdigit(ch1[0]));
- printf(" ch2 is decimal ? %d \n",isdigit(ch2[0]));
- printf(" ch1 is space ? %d \n",isspace(ch1[0]));
- printf(" ch1 is space ? %d \n",isspace(ch1[0]));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement