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

Relevant Pages

  • Re: Painful upgrade from XFree86 to X.Org
    ... session. ... HTH ... Jim ... To UNSUBSCRIBE, email to ...
  • Re: UDF producing #NAME?
    ... > Hi Jim, ... > Function ColumnLetterAs String ... > HTH ... >>> Hank Scorpio ...
  • Re: Number sequence
    ... ByVal fld As String) As String ... use two or three digits. ... '{increments a digit in a sequence field. ...
  • Re: Integer to string conversion
    ... I think Jim probably has the best solution but we haven't covered ... templates yet and they seem very confusing, ... I'm trying to convert an integer into a string. ... char buf; ...
  • Re: Speed this up for me, please
    ... Many thanks Jim. ... Function Sinfo_R1(ByRef lookupKey As String, ByRef lookupVal As String, _ ... Dim rng As Excel.Range ... The first row of the sheet contains titles for the columns. ...