-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
LX-i wrote:
| Joe Wright wrote:
|
|>
hp******@yahoo. com wrote:
|>
|>> can cobol read binary data written by fprintf (C function) ?
|>
|>
|> I'm not up on what COBOL can do but, fprintf() writes text data, not
|> binary data.
|
|
| COBOL can read and write both text and binary data - the key is, you've
| got to know the structure of the file. You can have variable-length
| records, so you could have one record with 10 characters, and another
| with 20K.
|
| I've never had experience interchanging data between the two languages,
| so I can't tell you the best way to do that, or any problems that may
| arise.
I /have/ had experience exchanging data between COBOL and C programs, both
through file transfer and by program call.
In general, COBOL 'records' are equivalent to C 'structures', and with
recognition of the rules each language uses to format data, a program written
in one language can read data written by the other. Some things to watch for...
1) COBOL strings are implicitly length delimited. C strings are explicitly
delimited by the \0 character. C programs must know the implicit length of the
string variable and use memcpy() to extract or populate string data.
2) COBOL recognizes a variety of fixed-point formats, including COMP-3 (IBM
'packed' BCD format). C does not recognize this variety of formats, especially
COMP-3. Some caution (and programming) will be required to pass fixed point
values between the two languages.
3) COBOL recognizes an implicit decimal point in it's fixed-point formats. C
does not recognize any decimal point in it's equivalent integer formats. Some
caution (and programming) will be required to pass fixed point values between
the two languages.
4) COBOL records have different padding rules than C structures. A common
padding pragma will have to be found between the two.
- --
Lew Pitcher
Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (
http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird -
http://enigmail.mozdev.org
iD8DBQFAnsxDagV FX4UWr64RAmv3AJ 40gp1cOfBnMSB/ZS6I/Wg6NldlMwCeJMRd
z/84sqQmiO/hrYHdIjD1PDQ=
=pvR1
-----END PGP SIGNATURE-----