Advertisement
Guest User

String comparison demo

a guest
Jan 20th, 2019
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main(void)
  4. {
  5.  
  6.     char a[100];
  7.     int b = 1, i;
  8.     char *q = "HELLO", *w = "HOLA", *e = "HALLO", *r = "BONJOUR", *t =
  9.     "CIAO", *y = "ZDRAVSTVUJTE";
  10.  
  11.  
  12.     while (1) {
  13.     scanf("%s", a);
  14.  
  15.     if (strcmp(a, "#") == 0) {
  16.         break;
  17.     } else if (strcmp(a, q) == 0) {
  18.         printf("Case %d: ENGLISH\n", b);
  19.     } else if (strcmp(a, w) == 0) {
  20.         printf("Case %d: SPANISH\n", b);
  21.     } else if (strcmp(a, e) == 0) {
  22.         printf("Case %d: GERMAN\n", b);
  23.     } else if (strcmp(a, r) == 0) {
  24.         printf("Case %d: FRENCH\n", b);
  25.     } else if (strcmp(a, t) == 0) {
  26.         printf("Case %d: ITALIAN\n", b);
  27.     } else if (strcmp(a, y) == 0) {
  28.         printf("Case %d: RUSSIAN\n", b);
  29.     } else {
  30.         printf("UNKNOWN");
  31.     }
  32.  
  33.     b++;
  34.     }
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement