[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] C++ programming: keeping count of data items read from file



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




Reply to: