I have a text file containing three columns of numbers; one column each for the x,y,z coordinates of a bunch of points. All numbers are between 0 and 1.
I have created the following structure:
typedef struct
{
double xcd, ycd, zcd;
} point;
I want to create a size-N array of structures of type point. Then I want to scan the text file line by line and for the nth particle, I want to put in the three numbers on the nth line into the respective xcd, ycd and zcd positions.
Tell me if there is some efficeint way of going about this.
Simply do it like has been shown five million billion kajillion times before, using
ifstream,vectorand various other accouterments.This will read in three doubles and put them in a
pointthen put a copy of thatpointinpoints. However, if the number of numbers in the file modulus 3 is not 0, it will stop and not add the incomplete point topoints.