Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > formatted input/output question

Reply
Thread Tools

formatted input/output question

 
 
dkk
Guest
Posts: n/a
 
      04-10-2006
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.

 
Reply With Quote
 
 
 
 
Michael Mair
Guest
Posts: n/a
 
      04-10-2006
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.
 
Reply With Quote
 
 
 
 
Herbert Rosenau
Guest
Posts: n/a
 
      04-12-2006
On Mon, 10 Apr 2006 20:30:21 UTC, "dkk" <(E-Mail Removed)> 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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question about some octal formatted output? 7stud -- Ruby 2 10-14-2007 11:23 PM
formatted output question with strings Jojo C++ 9 07-25-2007 08:09 AM
newbie question concerning formatted output Thomas Liesner Python 11 11-30-2005 08:47 AM
J2SE 1.5 Formatted Input Question Matt Java 3 10-19-2004 08:07 AM
How do I get nicely-formatted times? Leif K-Brooks Firefox 1 11-20-2003 10:22 PM



Advertisments