I'm creating a program that reads the author, title, and number of volumes from a file and prints out labels,
(ex. Adams A Complete History of the World Volume 1 of 10
Adams A Complete History of the World Volume 2 of 10 etc.)
To make it read properly and not infinitely loop, I had to change all of my variable to string. However, for future reference to the volume number, I need it to be int so I can compare the amount. My ideas for furthering the code with a do-while loop are commented in to show why I'd like vnum to have int value.
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main()
{
        ifstream fin;
        string author;
        string title;
        string vnum;
        int counter=1;
   fin.open("publish.txt", ios::in);
   while (!fin.eof())
   {
       getline(fin, author);
       getline(fin, title);
       getline(fin, vnum);
       //do
       //{
           cout << author << endl;
           cout << title << endl;
           cout << "Volume " << counter << " of " << vnum << endl;
           cout << endl;
           //counter++;
       //} while(counter < vnum);
   }
   fin.close();
   return 0;
}
File I'm reading from:
Adams
A Complete History of the World
10
Samuels
My Life of Crime
2
Baum
Wizard Stories
6
 
    