I'm just wondering how can I compare a union with another integer, my purpose is to code a sort of printf like and I'm managing the simple case like %d/%u/%i considering the size conversion : ll/l/hh/h/j/z, so basically I've the following union:
union all_integer
{
    char                        c;
    signed int                  nb;
    short int                   snb;
    long int                    lnb;
    long long int               llnb;
    size_t                      posnb;
    unsigned char               uc;
    unsigned int                unb;
    unsigned short int          usnb;
    unsigned long int           ulnb;
    unsigned long long int      ullnb;
};
because I can't know before which type I'll need to receive, and after that when I've something like that in case I use %d:
union all_integer u_allint;
u_allint.nb = va_arg(ap, int);
I want to print my data which is in my union u_allint so I give my union to a simple function for putmydata for example:
putdata(union all_integer u_allint)
{
     if (u_allint < 0)
     {
          return (ft_numlen_neg(u_allint));
     }
     if (u_allint > 9)
         return (1 + ft_numlen(u_allint / 10));
     if (u_allint > 0 && u_allint < 10)
          return (1);
     if (u_allint == 0)
        return (1);
     return (0);
}
just suppose that this function is capable to print correctly my data and the fact is I can't do that because i compare an union with an int and even if I try to do an other union in my function and give newunion.nb = 0 for have an union int compare with an union int, I can't compile with this message : invalid operands to binary expression ('union my_union' and 'union my_union').
so I'm pretty sure that I misunderstand something about union, but I didn't find a similar problem in other topic, so am I misunderstand something or maybe taking the problem by the wrong way?
 
     
     
     
    