Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. static uint16_t base[] = {1,2,3,4,5,6,7,8,9,10};
  5. static uint16_t pattern[] = {4,5};
  6.  
  7. int8_t startIdx (uint16_t *table, uint8_t tblSize, uint16_t *match)
  8. {
  9. for (int8_t idx =0; idx < tblSize-1; idx++)
  10. if (table[idx] == match[0] && table[idx+1] == match[1])
  11. return idx;
  12. return -1;
  13. }
  14.  
  15. int main()
  16. {
  17. printf("%d\n", startIdx(base, 10, pattern));
  18. return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement