Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. typedef struct {
  2. int* data;
  3. unsigned int len;
  4. } intarr_t;
  5.  
  6. intarr_result_t intarr_find( intarr_t* ia, int target, int* i )
  7. {
  8. unsigned int len = ia->len;
  9. if (ia == NULL)
  10. {
  11. return INTARR_BADARRAY;
  12. }
  13. else
  14. {
  15. for (int x = 0; x < len; x++)
  16. {
  17. if ((ia->data[x] == target) && (i != NULL))
  18. {
  19. *i = x;
  20. return INTARR_OK;
  21. }
  22. else
  23. {
  24. return INTARR_NOTFOUND;
  25. }
  26. }
  27. }
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement