以下是C实现的代码:
void FillStrWithZero(char* _strIn, char* _strOut, int _numBits)
{
if (_numBits <= strlen(_strIn))
{
return;
}
if (strlen(_strIn) < _numBits)
{
int loop = 0;
while (loop < _numBits - strlen(_strIn))
{
_strOut[loop] = '0';
loop++;
}
strcat(_strOut, _strIn);
}
}