I do not know how to write a function for this. I have written just the base line of the code, but I do not know how to finish it. Here is the description.

A void Function tagReader inputs the data collected by the cylinders; it has two parameters: the input file and an int count. The function inputs names, serial numbers, and location coordinates from the input file. The input file will have a descriptive name, an integer serial number and two double values representing map coordinates separated by blanks on each line. For each cylinder, echo print to the screen, the name, serial number and both coordinate values along with the value of the smaller coordinate value. Use an EOF controlled while loop. A count of the number of entries in the file will be returned to the caller via the reference parameter count.

tags1.txt
bsharkdata 1782 12.00 82.90
ftmyersfeb 7150 11.00 32.89
sandiego99 8800 15.20 52.76
turtles666 2180 11.00 14.09
turtles765 4223 11.90 17.10
FredsFish 4145 11.60 42.22
GreatBaReef 8673 10.00 11.40
VaBch77June 1111 13.50 44.00

tags2.txt
turtles686 2110 14.88 65.19
turtles995 1123 61.60 77.17
UKFishData 4145 99.04 22.98
Gr8BaReef2 8673 19.71 76.12
VaBch78876 1111 69.11 51.10
shark9987 1782 83.40 89.11
florida331 3130 14.01 52.89
florida876 6600 15.20 52.76
flKeys331 4410 64.66 56.22
flKeys877 6630 16.27 52.77

#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;
// function prototypes
void  tagReader ( ifstream& inFile, int&count);
void getEmployee ( string& who, double& rate, int &hours );
double paycheck (int hours, double rate);
void repeater ( string word, int num);
bool valid (int val);
void header ();


//=========================================================
int main() 
{    
    int count = 0; 
    ifstream inFile;
    int first, last;
    //----------------------------------------
    // Call function tagReader with tags1.txt
    inFile.open("tags1.txt");
    
    if (!inFile) 
    {
        cout << "\n\nError! - Invalid file name!  (1)\n\n";
        system ("pause");
        return 1;
     
    }

    cout <<"Results from tags1.txt :\n";
    tagReader ( inFile, count);    
    cout << "File tags1.txt had " << count << " data items. \n\n";
    inFile.close ();
    
    //----------------------------------------
    // Call function tagReader with tags2.txt
    inFile.clear (); 
    inFile.open("tags2.txt");
    if (!inFile) 
    {
        cout << "\n\nERROR!  Invalid file name! (2)\n\n";
        system ("pause");
        return 1;
     
    }

    cout <<"Results from tags2.txt :\n";
    tagReader ( inFile, count);    
    cout << "File tags2.txt had " << count << " data items. \n\n";
    inFile.close ();
    
    
   system("pause");
   return 0;
}
//-----------------------------------------------------
void tagReader (ifstream& inFile, int&count)
{    

}

I don't see an "an EOF controlled while loop" anywhere in the code at all. We can't help fix what's not there. Set up the WHILE loop, read from inFile, and when EOF is reached, exit the loop.

I do not know how to write EOF controlled while loops.

There are plenty of examples on this site. Use SEARCH.

Would you write a EOF loop as:

while(inFile){
}

and include it in the void tagReader section

Would you write a EOF loop as:

while(inFile){
}

I wouldn't. I'd do the search and learn from what I find.

Thanks for not helping me. I really appreciate it. I am only a student taking my first programming class.

I'm sorry. I didn't realize the only help that will be accepted is to have us write the code for you. I was hoping you'd be interested in learning enough to do some of your own work, not rely on others to do it for you. Again, sorry.

Its alright, I am not relying to you, but I tried searching and can not find an answer. Could you provide a link on eof controlled loops?

Here is my code: I do not know why when I compile it, on why does the last cylinder file print out multiple times int tags1 and tags2. I bolded them so you would see what I am talking about. Could someone please help me out?

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

using namespace std;
// function prototypes
void  tagReader ( ifstream& inFile, int&count);
void getEmployee ( string& who, double& rate, int &hours );
double paycheck (int hours, double rate);
void repeater ( string word, int num);
bool valid (int val);
void header ();


//=========================================================
int main() 
{    
    int count = 0; 
    ifstream inFile;
    string cylinder, serial;
    double num1, num2;
    double counter;
   
    //----------------------------------------
    // Call function tagReader with tags1.txt
    inFile.open("tags1.txt");
    
    if (!inFile) 
    {
        cout << "\n\nError! - Invalid file name!  (1)\n\n";
        system ("pause");
        return 1;
    }
         inFile >> cylinder;
         while (inFile) 
         {
    
         inFile>> serial;
         inFile >> num1;
         inFile >> num2;
         cout << fixed << showpoint << setprecision(2);
         cout <<"Cylinder: " << cylinder << " " << serial << " " << num1 << " " << num2 << endl << endl;   
         count = 1;
         counter++;
         while (count < num1)
         {     inFile >> cylinder ;
               inFile >> serial;
               inFile >> num1;
               inFile >> num2;
               cout << "\nCylinder: " << cylinder << " " << serial << " " << num1 << " " << num2 << endl << endl; 
               count++;        
         }
       }

    cout <<"Results from tags1.txt :\n";
    tagReader ( inFile, count);    
    cout << "File tags1.txt had " << count << " data items. \n\n";
    inFile.close ();
    
    //----------------------------------------
    // Call function tagReader with tags2.txt
    inFile.clear (); 
    inFile.open("tags2.txt");
    if (!inFile) 
         {
          cout << "\n\nERROR!  Invalid file name! (2)\n\n";
          system ("pause");
          return 1;
         }   
         
         inFile >> cylinder;
         while (inFile) 
         {
    
         inFile>> serial;
         inFile >> num1;
         inFile >> num2;
         cout << fixed << showpoint << setprecision(2);
         cout <<"Cylinder: " << cylinder << " " << serial << " " << num1 << " " << num2 << endl << endl;   
         count = 1;
         counter++;
         while (count < num1)
         {     inFile >> cylinder ;
               inFile >> serial;
               inFile >> num1;
               inFile >> num2;
               cout << "\nCylinder: " << cylinder << " " << serial << " " << num1 << " " << num2 << endl << endl; 
               count++;        
         }
       }

    cout <<"Results from tags2.txt :\n";
    tagReader ( inFile, count);    
    cout << "File tags2.txt had " << count << " data items. \n\n";
    inFile.close ();
    
   system("pause");
   return 0;
}
//**********************************************************************
//Function Name: GetLength
// Prompts the user to input the lenth of a rectangular room
// Returns the int value input by the user
//**********************************************************************
void tagReader (ifstream& inFile, int&count)
{    

}

Output:

Cylinder: bsharkdata 1782 12.00 82.90


Cylinder: ftmyersfeb 7150 11.00 32.89


Cylinder: sandiego99 8800 15.20 52.76


Cylinder: turtles666 2180 11.00 14.09


Cylinder: turtles765 4223 11.90 17.10


Cylinder: FredsFish 4145 11.60 42.22


Cylinder: GreatBaReef 8673 10.00 11.40


Cylinder: VaBch77June 1111 13.50 44.00


Cylinder: VaBch77June 1111 13.50 44.00


Cylinder: VaBch77June 1111 13.50 44.00


Cylinder: VaBch77June 1111 13.50 44.00


Cylinder: VaBch77June 1111 13.50 44.00


Cylinder: VaBch77June 1111 13.50 44.00


Cylinder: VaBch77June 1111 13.50 44.00

Results from tags1.txt :
File tags1.txt had 14 data items.

Cylinder: turtles686 2110 14.88 65.19


Cylinder: turtles995 1123 61.60 77.17


Cylinder: UKFishData 4145 99.04 22.98


Cylinder: Gr8BaReef2 8673 19.71 76.12


Cylinder: VaBch78876 1111 69.11 51.10


Cylinder: shark9987 1782 83.40 89.11


Cylinder: florida331 3130 14.01 52.89


Cylinder: florida876 6600 15.20 52.76


Cylinder: flKeys331 4410 64.66 56.22


Cylinder: flKeys877 6630 16.27 52.77


Cylinder: flKeys877 6630 16.27 52.77


Cylinder: flKeys877 6630 16.27 52.77


Cylinder: flKeys877 6630 16.27 52.77


Cylinder: flKeys877 6630 16.27 52.77


Cylinder: flKeys877 6630 16.27 52.77


Cylinder: flKeys877 6630 16.27 52.77


Cylinder: flKeys877 6630 16.27 52.77

Results from tags2.txt :
File tags2.txt had 17 data items.

Press any key to continue . . .

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.