Re: Converting packed decimal to a char array
Barbara Morris <[email protected]>
| Newsgroups | gmane.comp.lang.as400.c |
|---|---|
| Message-ID | <[email protected]> |
On 2015-01-10 05:56, Jevgeni Astanovski wrote:
>...
> It produces the following:
> After conversion A: ! 125678!
> What I expected is a number padded with zeros in the left.
> I have to check if the receiver program will accept the changed input...
>
Is the result correct except for the leading zeros? You could loop
through the result and replace the leading blanks with zeros. If you
find a sign, you'd have to move it to the beginning of the string.
Something like this:
for (i = 0; i < RcvLen; i++)
{
switch (szOutput[i])
{
case '-':
szOutput[i] = '0';
szOutput[0] = '-';
return;
case ' ':
szOutput[i] = '0';
break;
default:
return;
}
}
--
Barbara
--
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: C400-L-Zwy7GipZuJhWk0Htik3J/[email protected]
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request-Zwy7GipZuJhWk0Htik3J/[email protected]
Before posting, please take a moment to review the archives
at http://archive.midrange.com/c400-l.