|
发表于 2006-11-11 00:56:56
|
显示全部楼层
1.
void bin_dump_uint(unsigned int input)
{
int i = sizeof(unsigned int)*8 - 1;
while (i >= 0)
{
putchar('0' + (input>>i & 1));
if (i%8 == 0)
putchar(' ');
--i;
}
}
2.
char *remove_substr(char *str, unsigned int pos, unsigned int len)
{
int i;
char *temp, *sub_str = NULL;
unsigned int org_len = strlen(str);
if (pos > org_len)
return NULL;
if (len > org_len-pos)
len = org_len-pos;
temp = sub_str = (char*)malloc(org_len-len+1);
if (!sub_str)
return NULL;
memset(sub_str, 0x00, org_len-len+1);
for (i = 0; *str; ++i, ++str)
{
if (i < pos || i >= pos+len)
{
*temp = *str;
++temp;
}
}
*temp = 0;
return sub_str;
} |
|