#include <unistd.h>
#include <stdio.h>
void    ft_ultimate_div_mod(int *a, int *b);

int     main(void)
{

        printf("ex04\n");
        int     *ptr1;
        int     *ptr2;
        int     nb1 = 42; 
        //int   nb2 = 2;

        ptr1 = &nb1;
        ptr2 = &nb1;

        printf("before: %d, %d\n", *ptr1, *ptr2);
        ft_ultimate_div_mod(ptr1, ptr2);
        printf("after:  %d, %d\n", *ptr1, *ptr2);

        return (0);
}

void ft_ultimate_div_mod(int *a, int *b) 
{
        if (*b == 0)
                return;
        else
        {
                int     temp_mod;
                int     temp_div;

                temp_mod = *a % *b;
                temp_div = *a / *b;

                *a = temp_div;
                *b = temp_mod;

                /**wrong way
                a = &temp_div; 
                b = &temp_mod;
                **/
        }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: