字符串与整数的转换函数 atoi 和sprintf

    xiaoxiao2021-03-26  31

     

    atoi函数:把char类型的字符串转化为整形数     int n;     char str[] = "12345.67";     n = atoi(str);     n=12345

    sprintf函数:把整形数转化为一个字符串保存在char数组中 sprintf(s, "%d", 123); //产生"123" sprintf(s, "%8x", 4567); //小写16 进制,宽度占8 个位置,右对齐 sprintf(s, "%-8X", 4568); //大写16 进制,宽度占8 个位置,左对齐

    转载请注明原文地址: https://ju.6miu.com/read-662962.html

    最新回复(0)