formatted input/output question

Discussion in 'C Programming' started by dkk, Apr 10, 2006.

  1. dkk

    dkk Guest

    I am new to C programming. I need to read data from a formatted input
    text file (column-based), for example, "12345abcde678", I want to parse
    it into "123", "45", "ab", "cde", "678", and write them into Oracle
    database. I also need to do it in reverse, that is, read data from
    Orable database and write them into a file on column basis. I need to
    do this in ANSI C. Anybody can give some suggestions or sample code?
    Thanks.
     
    dkk, Apr 10, 2006
    #1
    1. Advertising

  2. dkk

    Michael Mair Guest

    dkk schrieb:
    > I am new to C programming. I need to read data from a formatted input
    > text file (column-based), for example, "12345abcde678", I want to parse
    > it into "123", "45", "ab", "cde", "678",


    You want to parse it following which rules?
    If you want to read three characters, then two, then two, then three
    and finally three again: Do so.
    If you want to use functions from the scanf() family, consider reading
    in whole lines using fgets() or something better (which, unfortunately,
    will not be part of the standard library) and using sscanf(). Always
    check the return value of sscanf() and friends. Be aware that arbitrary
    whitespace can creep in.

    > and write them into Oracle
    > database. I also need to do it in reverse, that is, read data from
    > Orable database and


    The topics discussed in comp.lang.c do not cover this part.

    > write them into a file on column basis.


    Use fprintf(). Read up on field width, precision and maybe flags.

    > I need to do this in ANSI C. Anybody can give some suggestions
    > or sample code?


    Read the comp.lang.c FAQ first. If you have problems writing the
    program, reduce your problems to a minimal compiling example and
    post this.
    The comp.lang.c FAQ can be found at <http://c-faq.com>.


    Cheers
    Michael
    --
    E-Mail: Mine is an /at/ gmx /dot/ de address.
     
    Michael Mair, Apr 10, 2006
    #2
    1. Advertising

  3. On Mon, 10 Apr 2006 20:30:21 UTC, "dkk" <> wrote:

    > I am new to C programming. I need to read data from a formatted input
    > text file (column-based), for example, "12345abcde678", I want to parse
    > it into "123", "45", "ab", "cde", "678", and write them into Oracle
    > database. I also need to do it in reverse, that is, read data from
    > Orable database and write them into a file on column basis. I need to
    > do this in ANSI C. Anybody can give some suggestions or sample code?
    > Thanks.
    >

    getc() gives you all on control about input streams you ever need.

    --
    Tschau/Bye
    Herbert

    Visit http://www.ecomstation.de the home of german eComStation
    eComStation 1.2 Deutsch ist da!
     
    Herbert Rosenau, Apr 12, 2006
    #3
    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. Matt
    Replies:
    3
    Views:
    438
    Eric Reitmaier
    Oct 19, 2004
  2. Thomas Liesner

    newbie question concerning formatted output

    Thomas Liesner, Nov 29, 2005, in forum: Python
    Replies:
    11
    Views:
    437
    Thomas Liesner
    Nov 30, 2005
  3. Jojo
    Replies:
    9
    Views:
    403
  4. davemullen

    CSV input -- Formatted output

    davemullen, Jan 18, 2012, in forum: Python
    Replies:
    1
    Views:
    254
    davemullen
    Jan 18, 2012
  5. 7stud --
    Replies:
    2
    Views:
    125
    mortee
    Oct 15, 2007
Loading...

Share This Page