Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int linearSearch(char array[][14], char key[], int size )
  6. {
  7. int i;
  8. for ( i = 0; i < size; ++i ) {
  9. if (strcmp(array[i],key) == 0) {
  10. return i;
  11. }
  12. }
  13. return -1;
  14.  
  15. }
  16.  
  17. int main (void) {
  18. char dstring[1][14];
  19. char hello[14] = "hello";
  20. dstring[0] = hello;
  21. printf("Result: %d", linearSearch(dstring, hello, 1));
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement