Convert sequence of hex digits

    xiaoxiao2023-11-12  155

    /* Convert sequence of hex digits on command line into a string, terminated by \n */ #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int i; for (i = 1; i < argc; i++) { unsigned long dig = strtoul(argv[i], NULL, 16); /*unsigned long strtoul(const char*nptr,char**endptr,int base) 参数1:字符串的起始地址 参数2:返回字符串有效数字的结束地址(二级指针) 参数3:转换基数(可以是2,8,16)*/ putchar((char) dig); } putchar('\n'); return 0; } /* 0 31 32 33 34 35 36 37 38 39 0123456789*/

     

    最新回复(0)