Reading from text files C++ -


I have a text file that has three columns of numbers; Each column for a group of digits is x, y, z . All the codes are between 0 and 1 .

I have created the following structure:

  typedef struct {double Xcd, ycd, zcd; } Point;   

I want to create structures of type-N array type point then I want to scan the text file line by line and n th particle, I want to place the n th line in the related code in three numbers> Xcd , ycd and zcd < / Code> statuses

Tell me if there are some effective ways to go about this. ifstream

Just like it, before it has been shown five million billion kajillion times , vector and other other accouterments.

  ifstream infile ("myfile.txt"); // Check that the file has been opened successfully (! Infel) {cerr & lt; & Lt; "Failure Can not Open File" & lt; & Lt; Endl; Cin.get (); Return EXIT_FAILURE; } // container in which all the points vector and lieutenant; Point & gt; Points; // To keep three calls to a temporary point, while we all read TMP; // reads in three dorms in three dables from infile in three coders while (Infil>> TMP .xcd & amp; infile> gt;> tmp.icd & amp; amp; infile & gt; ; & Gt; Tmp.Zcd) / Add a copy of TMP to the number points / push_back (tmp);   

It reads in three pairs and puts them in a point , then point of points . However, if the number of numbers in file modulus 3 is not 0, then it will stop and will not add an incomplete point to digits .

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

memcached - Django cache performance -