fin.get with link list and headers

Hi, I'm having issues with trying to use fin.get in my header file, everything displays properly except the first description. I'm using link list with classes and am new if anyone could help i would appreciate. below is everything

MAIN

#include<iostream>
#include<iomanip>
#include<fstream>
using namespace std;
#include "menutype.h"
void headerfn();
int main(){
headerfn();
menutype list1;
list1.listfn();


system("Pause");
return 0;
}//end of main

INPUT FILE
12345678901234567890123456789012345678901234567890
1234 Pickup tool box 50.00 .45 10
2345 Milwaukee drill 55.00 .45 10
3456 Atlas Machinist Lathe 495.00 .25 5
4567 Carbide tip blade 13.95 .50 10
5678 Mig welder 375.00 .25 5




HEADER FILE
class menutype{
private:
int id;
char name[30];
float price;
float multi;
float quanity;
float number;
menutype *head;
menutype *link;
public:
menutype();
menutype(int iid, char iname[30], float iprice, float imulti, float iquanity);
void listfn();
void printfn();
void addnodefn();
void deletenodefn();
void deleteallfn();
float newlistfn();
};//don't forget ;
//end of specification
//*******************************************************
//class ctype implementation
//*******************************************************
menutype::menutype(){
id=2342;
//name[30]="Bob ";
price=23;
multi=2;
quanity=3;
}//end of default constructor
//*******************************************************
//constructor with values
//*******************************************************
menutype::menutype(int iid, char iname[30], float iprice, float imulti, float iquanity){
id=iid;
name[30]=iname[30];
price= iprice;
multi=imulti;
quanity=iquanity;
}//end of constructor with values
//*******************************************************
//create the linked list
//*******************************************************
void menutype::listfn(){
ifstream fin;
string infile;
do{
fin.clear();
cout<<"Enter input file name: ";
cin>>infile;
fin.open(infile.c_str());
if(!fin){
cout<<"Input failure\n";
system("pause");
}//end of error check
}while(!fin);
cout<<"input file successfully opened\n";
menutype *nnptr, *cptr;

int iid;
char iname[30];
float iprice;
float imulti;
float iquanity;
head = new menutype;
fin.ignore(100,'\n');
fin>>iid;
fin.get(iname, 26);
fin>>iprice>>imulti>>iquanity;

//create first new node
head = new menutype(iid, iname, iprice, imulti, iquanity);


//all other nodes
cptr= head;//soo both point to first node
while(fin){nnptr=new menutype;
fin>>nnptr->id;
fin.get(nnptr->name, 26);
fin>>nnptr->price>>nnptr->multi>>nnptr->quanity;
cptr->link = nnptr;
cptr = nnptr;
if(fin.peek()=='\n')fin.ignore();
}//end of while
cptr->link=NULL;
cptr=NULL;
nnptr=NULL;
//call print function here
printfn();
cout<<"\nList successfully created\n\n";
}//end of listfn
//*******************************************************
void menutype::printfn(){
menutype *currptr;
currptr=head;
while(currptr!= NULL){
cout<<fixed<<showpoint<<setprecision(2);
cout<<left<<setw(10)<<currptr->id
<<setw(30)<<currptr->name
<<setw(11)<<currptr->price
<<setw(10)<<currptr->multi
<<setw(10)<<currptr->quanity
<<endl;

currptr=currptr->link;
}
}//end of printfn
Topic archived. No new replies allowed.