void* TRADE_Memset ( void* s, int c, size_t n )
{
volatile char* tmp = ( char* ) s;
if ( s == NULL )
{
return NULL;
}
while ( n-- > 0 )
{
*tmp++ = c;
}
return s;
}
正确
int main()
{
char amount[12]={0};
memset(amount,'0',11);
printf("amount=%s\n",amount);
}
错误:
int main()
{
char amount[12]={0};
memset(amount,'0',12);
printf("amount=%s\n",amount);
}