fork download
  1.  
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <unistd.h>
  6.  
  7. void ft_putchar(char c)
  8. {
  9. write(1, &c, 1);
  10. }
  11.  
  12. int ft_strlen(char *str)
  13. {
  14. int i;
  15.  
  16. i = 0;
  17. while (str[i] != '\0')
  18. {
  19. i++;
  20. }
  21. return (i);
  22. }
  23.  
  24. void ft_putstr(char *str)
  25. {
  26. write(1, str, ft_strlen(str));
  27. }
  28.  
  29.  
  30.  
  31.  
  32. void print_memory(const void *addr, size_t size)
  33. {
  34.  
  35. int i = 1;
  36. int number_of_element;
  37. number_of_element = (int)size/4;
  38.  
  39. while (i <= number_of_element)
  40. {
  41. if (i % 4 == 0)
  42. {
  43. printf("i = %d\n", i);
  44. fflush(stdout);
  45. ft_putstr("should be printed right after printf\n");
  46. }
  47.  
  48. i++;
  49. }
  50. }
  51.  
  52. int main(void)
  53. {
  54.  
  55. int tab[10] = {0, 23, 150, 255,
  56. 12, 16, 21, 42};
  57. print_memory(tab, sizeof(tab));
  58.  
  59. return 0;
  60. }
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
i = 4
should be printed right after printf
i = 8
should be printed right after printf