C++学习笔记:不用sizeof判断int类型占用几个字节

时间:2023-12-22 08:55:38
#include <stdio.h>
#include <string.h>

char *change(int val, int base, char *retbuf)
{
    static const char *str = "0123456789ABCDEF";
    char *p;
    ];

    p = buf+;
    *p = ;

    do { *--p = str[val % base]; } while( val /= base );
    strcpy(retbuf,p);
    return retbuf;
}

int main()
{

     ;

     ];
     printf(, binbuf), i);

     ;
      != i)
     {
          sum++;
          i = i<<;
          printf(, binbuf), i);
     }

     printf("sum = %d\n", sum);

}