|
From: H.S. on 6 May 2008 12:50 Hello, In a C++ program I am reading a data file for later processing and computations. While reading that data file, I want to keep track of data items (doubles) read. The data file is just a text file with N lines with C doubles in each line (N and C are known a priori). For now, I just read from the file stream in to a 2D array variable by reading each double at a time. Now I am trying to introduce some sanity checking into this reading block. Here is what I am trying to do: 1. Verify how many doubles I have read in each line. Must be C. If they are not C, then the input file is corrupt. 2. Verify that the total number of data items are NxC. This is simple, I just keep a track of how many numbers I have read. So, how do I go about doing (1) above? I was thinking of somehow checking if I have reached the end of line somehow (EOL?) but haven't found a method to do so. All I have found is EOF. thanks, ->HS -- To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
From: Robert Baron on 6 May 2008 13:10 On Tue, May 6, 2008 at 12:57 PM, Ron Johnson <ron.l.johnson(a)cox.net> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On 05/06/08 11:42, H.S. wrote: > > Hello, > > > > In a C++ program I am reading a data file for later processing and > > computations. While reading that data file, I want to keep track of data > > items (doubles) read. > > > > The data file is just a text file with N lines with C doubles in each > > line (N and C are known a priori). For now, I just read from the file > > stream in to a 2D array variable by reading each double at a time. > > > > Now I am trying to introduce some sanity checking into this reading > > block. Here is what I am trying to do: > > 1. Verify how many doubles I have read in each line. Must be C. If they > > are not C, then the input file is corrupt. > > 2. Verify that the total number of data items are NxC. This is simple, I > > just keep a track of how many numbers I have read. > > > > So, how do I go about doing (1) above? I was thinking of somehow > > checking if I have reached the end of line somehow (EOL?) but haven't > > found a method to do so. All I have found is EOF. > > This smells suspiciously like CompSci homework. > > - -- > Ron Johnson, Jr. > Jefferson LA USA > > We want... a Shrubbery!! And it is finals season. Rob.
From: Ron Johnson on 6 May 2008 13:10 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 05/06/08 11:42, H.S. wrote: > Hello, > > In a C++ program I am reading a data file for later processing and > computations. While reading that data file, I want to keep track of data > items (doubles) read. > > The data file is just a text file with N lines with C doubles in each > line (N and C are known a priori). For now, I just read from the file > stream in to a 2D array variable by reading each double at a time. > > Now I am trying to introduce some sanity checking into this reading > block. Here is what I am trying to do: > 1. Verify how many doubles I have read in each line. Must be C. If they > are not C, then the input file is corrupt. > 2. Verify that the total number of data items are NxC. This is simple, I > just keep a track of how many numbers I have read. > > So, how do I go about doing (1) above? I was thinking of somehow > checking if I have reached the end of line somehow (EOL?) but haven't > found a method to do so. All I have found is EOF. This smells suspiciously like CompSci homework. - -- Ron Johnson, Jr. Jefferson LA USA We want... a Shrubbery!! -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFIII4LS9HxQb37XmcRAsbtAKDfa5e5e+8t67npz6jvsIJY40fPiQCgmEa+ Js0qVrbUiDcRxy/5QLm4xxY= =6dN9 -----END PGP SIGNATURE----- -- To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
From: Jordi Gutiérrez Hermoso on 6 May 2008 13:20 On 06/05/2008, H.S. <hs.samix(a)gmail.com> wrote: > In a C++ program I am reading a data file for later processing and > computations. While reading that data file, I want to keep track of data > items (doubles) read. Use std::list and other standard data structures. It's C++. Don't use C arrays, ugh. If you are comfortable with IRC, I find that ##c++ on Freenode is full of bright people. And what does this have to do with Debian? - Jordi G. H. -- To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
From: H.S. on 6 May 2008 13:20 Jordi Guti�rrez Hermoso wrote: > On 06/05/2008, H.S. <hs.samix(a)gmail.com> wrote: >> In a C++ program I am reading a data file for later processing and >> computations. While reading that data file, I want to keep track of data >> items (doubles) read. > > Use std::list and other standard data structures. I am using them where ever I can. In this case however, I am using the data with ARPACK libraries and need to put it in a FORTRAN style 2D array. Everywhere else though, I am using C++ STL. > It's C++. Don't use C arrays, ugh. > > If you are comfortable with IRC, I find that ##c++ on Freenode is full > of bright people. > > And what does this have to do with Debian? er .. ahem .. yeah, sorry about that, should have had OT in the subject. But now that you mention this, let me explain a bit why I did not post it in C++ newsgroup. If you have visited that, it is full of people who want to discuss only the standard. I have had that experience, so gave it a shot here. Will try the IRC. Thanks, ->HS PS: I just put "OT" in the subject line. -- To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
|
Next
|
Last
Pages: 1 2 3 4 5 6 Prev: Clearing SWAP Next: Cannot partition a hard drive with the Etch installer |