Hello Phil,

You wrote:
>I am moving the characters to the output fields using
>strcpy.  This is when the problem shows up.  The packed
>fields wind up with blanks and all the character fields
>beyond the first packed field are missing 1 character.

C has no concept of fixed-length character fields.  They are simply arrays
of bytes and the C library functions for character strings expect character
values to end with x'00'.  strcpy() appends x'00' to the end of of the
target field.  Without seeing your code I suspect that the terminating null
is overwriting the first byte of each field or you are possibly copying more
data than you think because the source data may not have a terminating null.

Since you are dealing with fixed-length fields you must accept the
responsibility for handling the lengths.  The compiler will not help you at
all.  Use memcpy() and specify the number of bytes to copy.  You could also
possibly use strncpy() if you know that the length you actually copy is less
than or equal to the length of the source string.

I am not sure why the packed decimal fields are blank (I presume x'40') but
it may be a side-effect of how you are copying the data.

If that doesn't help then append a sample of your code and a copy of the
input data and output data in text and hex format so we can see what the
code is doing.

Does the input data map directly to the output data except that the output
data is formatted as separate fields?  I mean could you use CPYF
FMTOPT(*NOCHK)?  Or do you need to map differnt parts of the input data?

C is fine for bits and bytes but it sucks for database work -- you might
want to consider embedded SQL or the SQL CLI instead.

Regards,
Simon Coulter.
--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists
   http://www.flybynight.com.au/

   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175   mailto: shc@flybynight.com.au   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------



This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].