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

James Allsopp wrote:
Try something like this, just add some pointers;
scan is just a simple object and l is a class vector.

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;
scan n;
std::stringstream s(temp);
s >>;
s >> x;
s >> y;
return 0;

This is something like I meant when I said do it the C++ way, or the C way. Except that I gave a bad example of the C way, this is a better example, which is of a C++ way. It would help if I knew the C++ iostream stuff better. If this weren't so darned OT, I'd ask what a "scan" is.

(And is also an example of something that is wrong with the C++ standard library, when you need the c_str() member of string so often to get any real useful work done. Kind of defeats the purpose of having string in the first place.)

The totally unhelpful, but trying to be encouraging,

Mark Allums

To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx