|
From: H.S. on 6 May 2008 14:40 Mark Allums wrote: > > Not directly helpful, but some suggestions: > > 1. You might want to learn PERL or Python or Ruby, and do it there. hmm .. not sure how this will pan out in the long run, but for now, I am trying to keep it all within one program. > 2. If it has to be C++, learn enough PERL to write a filter for the data > file, and transform it so that it has one double per line. > 3. Debug the data generator /in situ/ with a good debugger, and bypass > the need to do the sanity checking. Totally agree with this. The sanity checking was mainly for the data files when some other user may use at a later date. > 4. Find a good C++ reference, and use it. There are several. > > Slightly more helpful: > > 1. Read one line at a time in as a string, then operate on the string. > 2. C++ has the ability to do everything that C does in a low level way, > but why? Use the C++ way, or use the C way: > > #include <cstdio> > #include <iostream> > . . . > using namespace std; > . . . > ios::sync_with stdio(); > . . . > int blah = fscanf(somefile,"%f %f %f %f\n", d1,d2,d3,d4); > if (blah != correctvalue) > { > dosomething(); > closefiles(); > cout << "error in data file\n"; > exit(1); > } > . . . > // etc. > > > (The ios::sync_with_stdio(); line may differ slightly on different C++ > implementations. I haven't used it in a while. May be spelled synch_. > Too lazy to look it up. > > The fscanf line may just be wrong. I quit writing C programs years ago. > Too old, memory failing.) Yup, that fscanf method looks interesting. I used that only when I program in C, but it might be judicious to use it in C++ in this situation. Never mind the syntax accuracy, I can fix that if need be. Looks like I may need to give this approach shot. 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: Hal Vaughan on 6 May 2008 14:50 On Tuesday 06 May 2008, H.S. wrote: > Ron Johnson wrote: > > Is this a binary file or a text file? > > hmm. Text. I made it clear in the original post. Ron has trouble keeping up with things like that. It's so hot where he lives his brain is often overheated with the lest bit of mental effort. Hal -- 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 15:10 Hal Vaughan wrote: > On Tuesday 06 May 2008, H.S. wrote: >> Ron Johnson wrote: >>> Is this a binary file or a text file? >> hmm. Text. I made it clear in the original post. > > Ron has trouble keeping up with things like that. It's so hot where he > lives his brain is often overheated with the lest bit of mental effort. > > Hal Thats okay. It is not a problem here. But had he committed this sacrilege in a newsgroups full of Linux "gurus" (you know, the RTFM type Linux/Unix puritans), he would have been flamed to cinders. :) -- To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
From: Hal Vaughan on 6 May 2008 15:20 On Tuesday 06 May 2008, H.S. wrote: > Hal Vaughan wrote: > > On Tuesday 06 May 2008, H.S. wrote: > >> Ron Johnson wrote: > >>> Is this a binary file or a text file? > >> > >> hmm. Text. I made it clear in the original post. > > > > Ron has trouble keeping up with things like that. It's so hot > > where he lives his brain is often overheated with the lest bit of > > mental effort. > > > > Hal > > Thats okay. It is not a problem here. But had he committed this > sacrilege in a newsgroups full of Linux "gurus" (you know, the RTFM > type Linux/Unix puritans), he would have been flamed to cinders. :) Interesting way to put it, since he is a puritan guru. (Or Linux guru, or puritan Linux guru -- I'm not sure which word should modify which here!) Hal -- To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
From: James Allsopp on 6 May 2008 15:40
hi, Try something like this, just add some pointers; scan is just a simple object and l is a class vector. HTH jim int nearest::readdata(std::string s, std::vector<scan> & l) { //read in scuba core list std::ifstream input(s.c_str()); std::string temp, pos, x ,y; char * t; std::cout <<"Reading " << s <<std::endl; while(!getline(input,temp).eof()) { scan n; std::stringstream s(temp); s >> n.name; s >> x; s >> y; n.glon=strtod(x.c_str(),&t); n.glat=strtod(y.c_str(),&t); l.push_back(n); } input.close(); return 0; } Hal Vaughan wrote: > On Tuesday 06 May 2008, H.S. wrote: > >> Hal Vaughan wrote: >> >>> On Tuesday 06 May 2008, H.S. wrote: >>> >>>> Ron Johnson wrote: >>>> >>>>> Is this a binary file or a text file? >>>>> >>>> hmm. Text. I made it clear in the original post. >>>> >>> Ron has trouble keeping up with things like that. It's so hot >>> where he lives his brain is often overheated with the lest bit of >>> mental effort. >>> >>> Hal >>> >> Thats okay. It is not a problem here. But had he committed this >> sacrilege in a newsgroups full of Linux "gurus" (you know, the RTFM >> type Linux/Unix puritans), he would have been flamed to cinders. :) >> > > Interesting way to put it, since he is a puritan guru. (Or Linux guru, > or puritan Linux guru -- I'm not sure which word should modify which > here!) > > Hal > > > -- To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org |