Advertisement

Cannt Open Struct

Started by May 26, 2002 05:10 PM
10 comments, last by Nukem 22 years, 9 months ago
Does OpenNGC need to read in the entire list or only one record? Remember that you'll have to create new structs before reading in, something like this untested function(assumes you want to read the entire list):

  void OpenNGC(char* filename, NGC** headNode){  ifstream input(filename, ios::binary);  int loopCount;  input >> loopCount; //assumes you've written the count to the file first      for (int i = 0; i < loopCount; ++i)  {    NGC* newNGC = new NGC;    newNGC->read(input);    if (*headNode == NULL)    {      newNGC->next = NULL;      *headNode = newNGC;    }    else    {      newNGC->next = *headNode;      (*headNode)->next = newNGC;    }  }}  


or (pseudocode)...

  void OpenNGC(char* filename, NGC** headNode){  ifstream input(filename, ios::binary);  double x,y,z;  for (all elements)  {     read in x,y,x     AddPoint(headNode, x,y,z);  }}  


[edited by - Alimonster on May 28, 2002 9:21:50 AM]
thx for the help!
--------------------------Nukemmsn: nukem996@hotmail.comaim: nukem996open source open mind

This topic is closed to new replies.

Advertisement