cobol and binary data written by C

Discussion in 'C Programming' started by hpy_awad@yahoo.com, May 9, 2004.

  1. Guest

    can cobol read binary data written by fprintf (C function) ?
     
    , May 9, 2004
    #1
    1. Advertising

  2. Malcolm Guest

    "" <> wrote
    >
    > can cobol read binary data written by fprintf (C function) ?
    >

    You're using fprintf() rather badly if you use it to write out binary data.
    It is designed for text.
    You'd have to ask in a COBOL group for an authorative answer, but I would be
    extremely surprised if the language didn't have support for reading
    arbitrary data files.
     
    Malcolm, May 9, 2004
    #2
    1. Advertising

  3. Joe Wright Guest

    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.

    --
    Joe Wright mailto:
    "Everything should be made as simple as possible, but not simpler."
    --- Albert Einstein ---
     
    Joe Wright, May 9, 2004
    #3
  4. Mike Guest

    > can cobol read binary data written by fprintf (C function) ?

    I don't know about fprintf or C funtions but COBOL can read and
    write binary data just fine. Care to explain a little better what
    it is you're actually trying to do?
     
    Mike, May 9, 2004
    #4
  5. LX-i Guest

    Joe Wright wrote:

    > 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.


    --
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ~ / \ / ~ Live from Montgomery, AL! ~
    ~ / \/ o ~ ~
    ~ / /\ - | ~ ~
    ~ _____ / \ | ~ http://www.knology.net/~mopsmom/daniel ~
    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
    ~ I do not read e-mail at the above address ~
    ~ Please see website if you wish to contact me privately ~
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
    LX-i, May 10, 2004
    #5
  6. Lew Pitcher Guest

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    LX-i wrote:
    | Joe Wright wrote:
    |
    |> 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

    iD8DBQFAnsxDagVFX4UWr64RAmv3AJ40gp1cOfBnMSB/ZS6I/Wg6NldlMwCeJMRd
    z/84sqQmiO/hrYHdIjD1PDQ=
    =pvR1
    -----END PGP SIGNATURE-----
     
    Lew Pitcher, May 10, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve C. Orr, MCSD
    Replies:
    1
    Views:
    586
    reaway lee
    Aug 24, 2003
  2. Batista, Facundo

    How to read files written with COBOL

    Batista, Facundo, May 10, 2004, in forum: Python
    Replies:
    7
    Views:
    1,213
    Buck Nuggets
    May 14, 2004
  3. Batista, Facundo

    RE: How to read files written with COBOL

    Batista, Facundo, May 10, 2004, in forum: Python
    Replies:
    1
    Views:
    531
    Steve Holden
    May 10, 2004
  4. none
    Replies:
    2
    Views:
    617
    Dennis Lee Bieber
    Sep 22, 2005
  5. KaiWen
    Replies:
    102
    Views:
    2,836
    Jorgen Grahn
    Sep 15, 2011
Loading...

Share This Page