Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: newby question on C I/O |
| Date | 2011-11-21 10:05 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <4ECA68A6.9040206@verizon.net> (permalink) |
| References | <0f0ee88e-09f4-43ca-8c95-84f9a4846455@c1g2000vbw.googlegroups.com> <j924gs$d7s$1@dont-email.me> <lptjc7tivkqh5ohopo9ie1tc2rrkoqul9a@4ax.com> |
On 11/21/2011 02:39 AM, David Thompson wrote: > On Fri, 04 Nov 2011 21:46:03 -0400, James Kuyper > <jameskuyper@verizon.net> wrote: > >> On 11/04/2011 06:07 PM, analyst41@hotmail.com wrote: >>> I have a file that looks like >>> >>> Value Cost Special_Status >>> 12 34 Yes >>> 21 44 yes >>> 32 43 no >>> ..................... >>> >>> I can read it into some arrays (or a data frame using R) using Fortran > <snip> >>> read (1,*,end=100) values(j),costs(j),statuses(j) >> >> The '*' in that READ statement, where a FORMAT would ordinarily go, >> indicates implicit formatting. A key difference between C and Fortran is > > Yes. Formally called 'list-directed' formatting. > >> that I/O is a built-in part of the Fortran language, while in C I/O is >> handled by standard library functions. Given the way C functions work, >> that means that something equivalent to the implicit formatting used by >> the READ statement above isn't feasible in C. The simplest approach > > Well, the syntax is a little different, but so is C stdio vs Fortran > classic explicit-format. Functionally, what Fortran list-directed > input does is a little different from what Standard C *scanf does, so > you would have to write maybe a page or two of code to fullly handle > it, which you could put in a utility function and reuse as needed. The key characteristic of Fortran list-directed input that I was talking about is the fact that you don't have to identify the types of the expressions you are printing; that information is implicitly determined by looking at the expressions themselves. C++ function overloading makes it feasible to do something similar in the <iostream> part of the C++ standard library (though you do have to provide your own overloads for operator<<() and operator>>() for any user-defined type), but I don't see any way to implement such a feature in "a page or two of code" in C. Could you explain how that would work?
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
newby question on C I/O "analyst41@hotmail.com" <analyst41@hotmail.com> - 2011-11-04 15:07 -0700
Re: newby question on C I/O Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-04 20:50 -0400
Re: newby question on C I/O "analyst41@hotmail.com" <analyst41@hotmail.com> - 2011-11-04 18:57 -0700
Re: newby question on C I/O "analyst41@hotmail.com" <analyst41@hotmail.com> - 2011-11-07 17:10 -0800
Re: newby question on C I/O Ian Collins <ian-news@hotmail.com> - 2011-11-08 14:47 +1300
Re: newby question on C I/O "BartC" <bc@freeuk.com> - 2011-11-08 01:52 +0000
Re: newby question on C I/O Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-07 20:56 -0500
Re: newby question on C I/O Edward Rutherford <edward.p.rutherford79@REMOVETHIS.gmail.com> - 2011-11-08 20:27 +0000
Re: newby question on C I/O Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-08 20:48 -0500
Re: newby question on C I/O "BartC" <bc@freeuk.com> - 2011-11-09 11:12 +0000
Re: newby question on C I/O James Kuyper <jameskuyper@verizon.net> - 2011-11-09 07:02 -0500
Re: newby question on C I/O Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-09 16:12 +0000
Re: newby question on C I/O - SUCCESS "analyst41@hotmail.com" <analyst41@hotmail.com> - 2011-11-08 16:12 -0800
Re: newby question on C I/O James Kuyper <jameskuyper@verizon.net> - 2011-11-04 21:46 -0400
Re: newby question on C I/O Ike Naar <ike@iceland.freeshell.org> - 2011-11-05 06:52 +0000
Re: newby question on C I/O Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-11-05 04:13 -0700
Re: newby question on C I/O James Kuyper <jameskuyper@verizon.net> - 2011-11-05 08:16 -0400
Re: newby question on C I/O Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-05 09:21 -0400
Re: newby question on C I/O Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-05 09:13 -0400
Re: newby question on C I/O David Thompson <dave.thompson2@verizon.net> - 2011-11-21 02:39 -0500
Re: newby question on C I/O James Kuyper <jameskuyper@verizon.net> - 2011-11-21 10:05 -0500
Re: newby question on C I/O David Thompson <dave.thompson2@verizon.net> - 2012-01-19 02:40 -0500
Re: newby question on C I/O "BartC" <bc@freeuk.com> - 2011-11-06 21:23 +0000
Re: newby question on C I/O "analyst41@hotmail.com" <analyst41@hotmail.com> - 2011-11-10 18:00 -0800
Re: newby question on C I/O Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-11-11 01:35 -0800
Re: newby question on C I/O gazelle@shell.xmission.com (Kenny McCormack) - 2011-11-11 11:26 +0000
Re: newby question on C I/O Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-11-11 04:41 -0800
Re: newby question on C I/O gazelle@shell.xmission.com (Kenny McCormack) - 2011-11-11 14:14 +0000
Re: newby question on C I/O Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-11-11 07:02 -0800
Re: newby question on C I/O gazelle@shell.xmission.com (Kenny McCormack) - 2011-11-11 15:44 +0000
csiph-web