Advertisement
eg0rmaffin

any_ft

Jul 15th, 2019
340
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.  
  3. #include <stdlib.h>
  4.  
  5.  
  6. int     ft_any(char **tab, int (*f)(char*))
  7. {
  8.     int run;
  9.  
  10.     run = 0;
  11.     while (tab[run] != '\0')
  12.     {
  13.         if ((*f)(tab[run]) == 1)
  14.             return (0);
  15.         ++run;
  16.     }
  17.     return (1);
  18. }
  19.  
  20. int starts_with_z(char* str)
  21. {
  22.     return str[0] == 'z';
  23. }
  24.  
  25. int main(int argc, char** argv)
  26. {
  27.     printf("%d", ft_any(argv + 1, starts_with_z));
  28.     if (argc < 2)
  29.         return 1;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement