void cargarpaq()
{
char oriDirTmp[1];
char desDirTmp[1];
char msgTipTmp[2];
char msgRecTmp[2];
ItoaMsg(&oriDirTmp[0], "", device1, 1, 0);
oriDirSnd = oriDirTmp[0];
ItoaMsg(&desDirTmp[0], "", coordin, 1, 0);
desDirSnd = desDirTmp[0];
ItoaMsg(&msgTipTmp[0], "", msgCateg, 2, 0);
msgTipSnd[0] = msgTipTmp[0];
msgTipSnd[1] = msgTipTmp[1];
ItoaMsg(&msgRecTmp[0], "", msgTarea, 2, 0);
msgRecSnd[0] = msgRecTmp[0];
msgRecSnd[1] = msgRecTmp[1];
rellenela(allSnd);
}已解决! 转到解答。
extern BOOL gpfunc_itoa (uint16 value, uint8 buf[], uint16 buf_size, uint16* bytes_written);
/*
DESCRIPTION Int to ASCII character conversion for 16-bit integers.
PARAMETERS
[value] The integer value to convert.
[buf] A pointer to an allocated buffer of [buf_size] bytes that
will contain the null-terminated string which is the result.
[buf_size] The size of [buf] in bytes.
[bytes_written] A pointer to an allocated uint16 variable which will contain
the number of bytes written by the function.
RETURNS TRUE if the function was successful, otherwise FALSE.
*/
BOOL gpfunc_itoa (uint16 value, uint8 buf[], uint16 buf_size, uint16* bytes_written)
{
BOOL result;
uint16 div;
uint16 i;
BOOL remove_zeroes;
i = 0U;
remove_zeroes = TRUE;
div = 10000U;
while((div != 0U) && (i < buf_size))
{
uint8 ch;
ch = (uint8)((value / div) + '0');
if(remove_zeroes && (ch == '0'))
{
if(value == 0U)
{
buf[i] = ch;
i++;
break;
}
else
{
; /* skip leading zeroes */
}
}
else
{
buf[i] = ch;
remove_zeroes = FALSE;
i++;
}
value %= div;
div /= 10U;
}
if(i == buf_size)
{
result = FALSE;
}
else
{
buf[i] = '\0';
result = TRUE;
}
return result;
}