展开全部
#include <stdio.h>
int main()
{
int lVal = 112; //将lVal转换成二进制形式
int i = 0, n = 0,t[64] = {0}, k = 0;
char sz[65] = {0};
do
{
t[k++] = lVal%2;
lVal /= 2;
} while (lVal);
for ( i = 0, n = 0; k > 0; i++)
{
if( i < 32 - k)
sz[i] = '0';
else
sz[i] = '0' + t[--k];
}
char c1[9] = {0} , c2[9]= {0}, c3[9]= {0}, c4[9]= {0};
strncpy(c1, sz, 8);
strncpy(c2, sz+8, 8);
strncpy(c3, sz+16, 8);
strncpy(c4, sz+24, 8);
printf(sz);
printf("\n%s %s %s %s\n", c1, c2, c3, c4);
}
int main()
{
int lVal = 112; //将lVal转换成二进制形式
int i = 0, n = 0,t[64] = {0}, k = 0;
char sz[65] = {0};
do
{
t[k++] = lVal%2;
lVal /= 2;
} while (lVal);
for ( i = 0, n = 0; k > 0; i++)
{
if( i < 32 - k)
sz[i] = '0';
else
sz[i] = '0' + t[--k];
}
char c1[9] = {0} , c2[9]= {0}, c3[9]= {0}, c4[9]= {0};
strncpy(c1, sz, 8);
strncpy(c2, sz+8, 8);
strncpy(c3, sz+16, 8);
strncpy(c4, sz+24, 8);
printf(sz);
printf("\n%s %s %s %s\n", c1, c2, c3, c4);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询