When I excute my program and open up the text file, it only reads me the 1234 then junk below it. I have no clue what do. Anything is welcome. Below is my .cpp file
my text file looks something like this
1234 jack hammer 75.00 .45 10
5678 Daffy Drill 25.00 .67 10
9887 Flash light 30.00 .87 10
#include<iostream>
#include<conio.h>
#include<fstream>
#include<iomanip>
using namespace std;
//******************************************************************************
struct acmetype{
int pid;
char description[25];
float wholesale;
float markup;
int quantity;
acmetype *link;
};
ifstream fin; //global variable
void headerfn();
void fileopen();
void inputfn(acmetype *&head);
void printfn(acmetype *&head);
//*******************
//* Begin of Main *
//*******************
int main(){
system("color F0");
headerfn();
fileopen();
acmetype *head;
inputfn(head);
printfn(head);
cout<<endl<<endl;
system("PAUSE");
}//end of main
//******************************************************************************
void fileopen(){
string tools;
int pid;
char description;
fin.open("tools.txt");
if (!fin)
{
cout << "Error opening output file. Go Play Basketball like Kobe!!"<<endl<<endl;
system("PAUSE");
getch();
}
}
//***************************************************************************
void inputfn(acmetype *&head){
acmetype *currptr, *nnptr;
int counter= 0;
char description[25];
head = new acmetype;//creating first node
fin>>head->pid;
currptr = head;//curr ptr pointing at head and first node is ready.
counter++;
while(fin){
nnptr= new acmetype;
fin>>nnptr->pid;
fin.getline(description, 25);
// fin.getline(acmetype.description[25]);
currptr->link = nnptr;
currptr = currptr->link;
if(fin.peek()=='\n')fin.ignore();//check for next character
counter++;
}//end of while
currptr->link= NULL;
currptr= NULL;
nnptr= NULL;
}//end of inputfn
//****************************************************************************
void printfn(acmetype *&head){
acmetype *currptr;
//print all data members
currptr = head;
while(currptr!=NULL){
cout<<currptr->pid<<endl;
currptr=currptr->link;
if(fin.peek()=='\n')fin.ignore();
}//end of while