ifstreams

New Message Reply Date view Thread view Subject view Author view

wasileskib++at++adadv1.mdc.com
Wed, 24 Jul 1996 09:31:14 -0500


I have encountered something strange
while porting code from an RE2 to an IR machine.
My appliation reads in a list of terrain files
, listed line by line in a textfile. On the RE2
the file is read in 100% correct with no problems.
However, on the IR, it is skipping every other line
faithfully. Has anyone encountered this? Here is an
list of the routine:

int LoadTerrainFiles(const char *fname)
{
  int const max_line = 30;
  char buff[max_line];
  char *model_file = (char *)calloc(max_line,sizeof(char));
  ifstream terrain_list(fname, ios::in);

  NUM_TERRAIN_FILES = 0;
  terrain = new pfSwitch;

  if(!terrain_list)
     return (-1);
  else
  {
    while(terrain_list.getline(buff,max_line)&&
            NUM_TERRAIN_FILES < MAX_TERRAIN_FILES)
    {

      strcpy(model_file,&buff[0]);

      StripBeginEndBlanks(&model_file);
      terrain_node[NUM_TERRAIN_FILES] = pfdLoadFile(model_file);

      if(terrain_node[NUM_TERRAIN_FILES] == NULL)
         pfNotify(PFNFY_NOTICE, PFNFY_PRINT,
                 "Warning: Terrain file %s NOT loaded.\n\n",buff);
      else
      {
        terrain->addChild(terrain_node[NUM_TERRAIN_FILES]);
        NUM_TERRAIN_FILES++;
      }
    }
    terrain_list.close();
    cout << "Number of Terrain Files loaded: " << NUM_TERRAIN_FILES << endl;
    otw_scene->addChild((pfNode *)terrain);
    terrain->setVal(PFSWITCH_ON);
  }

  free(model_file);
  return 1;
}

The function returns without error and never gets a NULL
node but only reads in half of files. Help?

=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:53:13 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.