By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,903 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,903 IT Pros & Developers. It's quick & easy.

formatted input/output question

P: n/a
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.

Apr 10 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.
Apr 10 '06 #2

P: n/a
On Mon, 10 Apr 2006 20:30:21 UTC, "dkk" <ta******@gmail.com> 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!
Apr 12 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.