Advertisement
Guest User

Untitled

a guest
Jul 8th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.35 KB | None | 0 0
  1. /*Main test j02*/
  2. /* Ligne de compilation : gcc [-Wall -Wextra -Werror] main.c ex##/file.c ex##/file.c */
  3. /* execution : ./a.out */
  4. /* Si vous utilisez ca vous etes assez grand pour ne pas prendre -42 pour utilisation de printf en le rendant sur git */
  5.  
  6. #include <unistd.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9.  
  10. void    ft_ft(int *ptr);
  11. void    ft_ultimate_ft(int *********nbr);
  12. void    ft_swap(int *a, int *b);
  13. void    ft_div_mod(int a, int b, int *div, int *mod);
  14. void    ft_ultimate_div_mod(int *a, int *p);
  15. void    ft_putstr(char *str);
  16. int     ft_strlen(char *str);
  17. char    *ft_strrev(char *str);
  18. void    ft_sort_integer_table(int *tab, int size);
  19. void    ft_sort_integer_table(int *tab, int size);
  20.  
  21. void    ft_putchar(char c)
  22. {
  23.     write(1, &c, 1);
  24. }
  25.  
  26. void print(int *tab, int size)
  27. {
  28.     int i = 0;
  29.     while(i < size)
  30.     {
  31.         printf("tab[%d]=%d\n", i, tab[i]);
  32.         i++;
  33.     }
  34. }
  35.  
  36. int     main(void)
  37. {
  38.  
  39.     int value;
  40.     int *p;
  41.     int *z = &value;
  42.     int **zz = &z;
  43.     int ***zzz = &zz;
  44.     int ****zzzz = &zzz;
  45.     int *****zzzzz = &zzzz;
  46.     int ******zzzzzz = &zzzzz;
  47.     int *******zzzzzzz = &zzzzzz;
  48.     int ********zzzzzzzz = &zzzzzzz;
  49.     int *********nbr = &zzzzzzzz;
  50.     int *a;
  51.     int *b;
  52.     int i;
  53.     int j;
  54.     int q;
  55.     int w;
  56.     int *div;
  57.     int *mod;
  58.     int d;
  59.     int m;
  60.     char *stra = malloc(sizeof(char) * 4);
  61.     char *strb = malloc(sizeof(char) * 5);
  62.     int tab[5];
  63.  
  64.     tab[0] = 4;
  65.     tab[1] = 1;
  66.     tab[2] = 4;
  67.     tab[3] = 5;
  68.     tab[4] = -1;
  69.     stra[0] = 'a';
  70.     stra[1] = 'b';
  71.     stra[2] = 'c';
  72.     stra[3] = 'd';
  73.     strb[0] = 'a';
  74.     strb[1] = 'b';
  75.     strb[2] = 'c';
  76.     strb[3] = 'd';
  77.     strb[4] = 'e';
  78.     value = 21;
  79.     i = 123;
  80.     j = 0;
  81.     p = &value;
  82.     a = &i;
  83.     b = &j;
  84.     q = 13;
  85.     w = 2;
  86.     d = 0;
  87.     m = 0;
  88.     div = &d;
  89.     mod = &m;
  90.     ft_ft(p);
  91.     printf("ft_ft return_value = %d\n", *p);
  92.     ft_ultimate_ft(nbr);
  93.     printf("ft_ultimate_fr return_value = %d\n", *********nbr);
  94.     ft_swap(a, b);
  95.     printf("ft_swap a(original:123)=%d | b(original=0)=%d\n", *a, *b);
  96.     ft_div_mod(q, w, div, mod);
  97.     printf("ft_div_mod resultat=%d|reste=%d\n", *div, *mod);
  98.     ft_ultimate_div_mod(b, p);
  99.     printf("ft_ultimate_div_mod resultat=%d|reste=%d\n", *b, *p);
  100.     ft_putstr("coucou");
  101.     printf("\nstrlen de l'alphabet = %d\n", ft_strlen("qwertyuiopasdfghjklzxcvbnm"));
  102.     printf("strrev de abcd =%s\n", ft_strrev(stra));
  103.     printf("strrev de abcde =%s\n", ft_strrev(strb));
  104.     ft_sort_integer_table(tab, 5);
  105.     print(tab, 5);
  106.     write(1, "\nEND", 4);
  107.     return (0);
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement