i have this program trying to read from a file but i keep getting this error message what am i doing i cant figure it out.

#include<iostream>
#include<cstdlib>
#include<cstring>
#include"assignment9.h"
#include<fstream>
using namespace std;

const int MAX_LEN = 30;

int numofRecords()
{

  int numRecords;

  cout <<"number of courses to process: ";
  cin >> numRecords;

  cin.ignore(999, '\n');

  return numRecords;
}

int getdata(std::fstream& fin)
{
  //  ifstream fin;
   char inputfilename[MAX_LEN + 1];

   cout << "Input filename(up to"<<MAX_LEN<<" characters): ";
   cin.get(inputfilename, MAX_LEN + 1, '\n');
   cin.ignore(999, '\n');


   fin.open(inputfilename, ios::in);
   if(fin.fail())

   {
     cout<<"Error opening input file"<< inputfilename;
     cout<<"press enter or return to continue...."<<endl;

     cin.get();

     exit(EXIT_FAILURE);
   }

    int numofRecords = 0;
    inventory records;

    fin >> ws;

    while(!fin.eof())
   {
     fin >> records.id;
     if(fin.eof())

   {
     cerr<<"Input file contains an incomplete record"<<endl;
     break;
   }

   fin.ignore(999,'\n');

   fin>>ws;

   fin.get(records.description, MAX_LEN +1,'\n');
   if(fin.eof())
   {

    cerr<<"inputfIle contains an incomplete record"<<endl;
    break;
   }

   fin.ignore(999,'\n');

   fin >>ws;

   fin >>records.wholesalePrice;

   if(fin.eof())
   {
    cerr<<"inputfile contains an incomplete record"<<endl;
    break;
   }
   fin.ignore(999,'\n');


   fin >> ws;
   fin >>records.retailPrice;
   if(fin.eof())
   {
    cerr << "inputfile contains an incomplete record"<<endl;
    break;
    }
   fin.ignore(999,'\n');


   fin >> ws;
   fin>>records.avgWeeklySales;
   if(fin.eof())
   {
    cerr << "inputfile contains an incomplete record"<<endl;
    break;
    }

   fin >> ws;
   fin >>records.quantityInStock;

   numofRecords ++;

    cout << records.id<< endl;
      cout << records.description;
      cout << records.wholesalePrice<< endl;
      cout << records.retailPrice<< endl;
      cout << records.avgWeeklySales<< endl;
      cout << records.quantityInStock << endl;
      cout << endl;
      cout << "# of courses scanned: " << numofRecords << endl;
      cout << endl;

  }

   fin.seekg(0);
   fin.clear();

   return numofRecords;
this the error i keep getting 
}

<< moderator edit: added [co[u][/u]de][/co[u][/u]de] tags >>

/usr/lib/gcc/i386-redhat-linux/3.4.4/../../../crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status

this the header file

#include<iostream>
#include<fstream>
#include<cstring>
#include<cstdlib>

struct inventory
{
   int id;
   char description[41];
   double wholesalePrice;
   double retailPrice;
   double avgWeeklySales;
   double quantityInStock;
};

int numofRecords();

int getdata(std::ifstream& fin);

#endif

<< moderator edit: fixed [co[u][/u]de][/co[u][/u]de] tags >>

i have this program trying to read from a file but i keep getting this error message what am i doing i cant figure it out.

It might be beneficial to post the error message. It might also be beneficial to post the header file.

You have a stray #endif in your header file. Perhaps you meant to add this onto the beginning:

#ifndef HEADER_H
#define HEADER_H 1
ad/usr/lib/gcc/i386-redhat-linux/3.4.4/../../../crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'

Well, there you go. main() isn't defined.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.