Respond to this messageReturn to Index
Original Message
  • Help needed with structures...
    • Unseen Machine (no login)
      Posted May 1, 2011 12:29 AM

      I cant assign values to the variables in the structure! I dont know enough C++ to understan the error report (something about Did i mean -> )

      Here's the code (VC++08), any ideas or tips would be great. As you can see it is coursework so please dont just do it for me...

      // JohnOnyon_10036178_Coursework1_C++.cpp : Defines the entry point for the console application.
      #include "stdafx.h"
      #include "iostream"
      #include "fstream"
      #include "string"
      #include "iomanip"
      #include "ctime"
      #include "cstdio"

      using namespace std;

      //Prototype function declerations
      ifstream& OpenRecords(const char* FilePntr);

      //This struct defines how the records file is both built and read.
      //4 SalesRecord structures must exist for a complete record section.
      //Each SalesRecord is an individual employees sales for that day.
      struct SalesRecord
      {int Item1, Item2, Item3, Item4, Item5;};

      int main ()
      // Title
      // Get the file stream
      ifstream& fileStream = OpenRecords("SalesRecords.txt");

      // Count the number of entries, create array to match and load the data.
      // This is done by seeking for the end if file flag and dividing the pointers
      // position by the size of the SalesRecord structure.
      int NumberOfRecords = fileStream.tellg () / sizeof(SalesRecord);
      // Create array of SalesRecord struct and store the data in it.
      cout while(!fileStream.eof())
      int value = 0;
      fileStream >> value;

      // Allow the user to see the final screen before exit.
      return 0;

      // This function checks for the records files existance, if it exists, returns a pointer to the
      // open file stream, If it does not exist then the program creates a dummy records file and
      // restarts.
      ifstream& OpenRecords(const char* FilePntr)
      // Make sure the records file exists before running the program
      cout // Attempt to open the file, if good return pointer of open file stream else report error and exit.
      ifstream* CheckFileStream = new ifstream(FilePntr);
      if (CheckFileStream->good())
      cout }
      else // If file not found create a dummy records file and restart the loading.
      cout delete CheckFileStream;
      ofstream* CheckFileStream = new ofstream(FilePntr);
      // Seed random number generator
      int MaxSales = 10, MinSales = 0;
      int RandNum;

      SalesRecord* sRec = new SalesRecord();
      RandNum = rand();
      sRec.Item1 = (RandNum % MaxSales) + MinSales;

      return *CheckFileStream;
    Your Name
    Message Title
    Message Text
    Image Services
    Enable formatted text (what's this?)

     Copyright © 1999-2017 Network54. All rights reserved.   Terms of Use   Privacy Statement