思控肩官

 

随笔分类 -  C

sprintf四舍五入
摘要:#include<stdio.h> int main(int argc,const char*argv[]){ double a=0.123456789; char s1[50]; sprintf(s1,"%.1f",a); printf("取1位小数结果为:%s\n",s1); sprintf(s 阅读全文

posted @ 2021-01-05 12:02 思控肩官 阅读(578) 评论(0) 推荐(0)

进制数使用
摘要:二进制 C平台不支持 我使用时为了避免出现中间过程导致转换数据错误,我一般使用字符串带入,然后去判断。 unsigned char l5c_pilot[][16] = { "1001011001100", "0100011110110", }; for (ii = 0; ii < 2; ii = i 阅读全文

posted @ 2020-08-04 16:59 思控肩官 阅读(138) 评论(0) 推荐(0)

巧用联合体
摘要:void test(void) { union char2int{ unsigned char str[4]; unsigned int data; } tmp; tmp.str[0] = '1'; tmp.str[1] = '2'; tmp.str[2] = '3'; tmp.str[3] = ' 阅读全文

posted @ 2020-08-03 19:36 思控肩官 阅读(92) 评论(0) 推荐(0)

导航