Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <stdio.h>
  2. #include<string.h>
  3.  
  4.  
  5. int main()
  6. {
  7.     char *char_array[]={"red_led","blue_led","buzzer","distance"};
  8.     char *input_array[]={"red_led","2"};
  9.     int i;
  10.     int state;
  11.    
  12.    
  13.     for(i=0;i<4;i++)
  14.     {
  15.    if(0==(strcmp(char_array[i],input_array[0])))
  16.    {
  17.        state=i;
  18.    }
  19.     }
  20.    
  21.    
  22.    printf("output %d\n",state);
  23.    
  24.    
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement