formatted input/output question

D

dkk

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

Michael Mair

dkk said:
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
 
H

Herbert Rosenau

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!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top