Hello, I cant figure out what is wrong with this.
Code:
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <stdlib.h>
using namespace std;
//#include "songs.h"
//prototypes
void getData();
void printData();
//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
int main()
{
int many = 0; //how many things are in the file
string filename;
char choice;
cout <<"Please enter the filename holding the initial database: ";
getline(cin, filename);
cout << endl;
getData();
if (many > 0)
{
cout << "Initial DB: " << endl;
cout << endl;
cout << endl;
printData();
cout << endl;
cout << endl;
cout << "Please choose one: " << endl;
cout << "1. Print out Song Times" << endl;
cout << "2. Determine the total playing time of the playlist " << endl;
cout << "3. Quit " << endl;
cout << endl;
cin >> choice;
cout << endl;
cout << endl;
while (cin)
{
if (choice == '1')
{
//printData()
cout << "Sorry, can't handle yet..." << endl;
}
else if (choice == '2')
{
//songs.two ()
cout << "Sorry, can't handle yet..." << endl;
}
else if (choice == '3')
{
exit(1);
}
else
{
cout << "Invalid choice -- Choose again" << endl;
cout << endl;
cout << endl;
cout << "Please choose one: " << endl;
cout << "1. Print out a list of the times of the songs " << endl;
cout << "2. Determine the total playing time of the playlist " << endl;
cout << "3. Quit " << endl;
cout << endl;
cin >> choice;
}//else
}//while
}//if
else
{
cout << "Empty data file -- program terminating..." << endl;
cout << endl << endl
<<"End program..." << endl << endl;
}//else
return 0;
}//main
//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
void getData()
{
ifstream
InStream;
int mins;
int secs;
string filename;
cout << endl;
cout << "Attempting to open the file " << filename << endl;
InStream.clear();
InStream.open(filename.c_str(), ios::in);
if(InStream.fail() )
{
cout << "ERROR: input file called " << filename
<< "didn't open " << endl;
cout << endl;
cout << "Program terminating ... " << endl;
exit(-1);
} //if fail
while (InStream)
{
getline (InStream, mins, ':');
InStream >> secs;
}
}//getData
//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
void printData()
{
int mins;
int secs;
cout << " Song Times " << endl;
cout << "--------------" << endl;
for (int i=0; i = i; i++)
{
cout << mins << ":" << secs << endl;
}//for
}//printData
There are three errors:
error C2784: 'class std::basic_istream<_E,_Tr> &__cdecl std::getline(class std::basic_istream<_E,_Tr> &,class std::basic_string<_E,_Tr,_A> &,const
_E)' : could not deduce template argument for 'class std::basic_istream<_E,_Tr> &' from 'class std::basic_ifstream<char,struct std::char_traits<char> >'
error C2784: 'class std::basic_istream<_E,_Tr> &__cdecl std::getline(class std::basic_istream<_E,_Tr> &,class std::basic_string<_E,_Tr,_A> &,const
_E)' : could not deduce template argument for 'class std::basic_string<_E,_Tr,_A> &' from 'int'
error C2780: 'class std::basic_istream<_E,_Tr> &__cdecl std::getline(class std::basic_istream<_E,_Tr> &,class std::basic_string<_E,_Tr,_A> &)' : ex
pects 2 arguments - 3 provided
c:\program files\microsoft visual studio\vc98\include\string(145) : see declaration of 'getline'
Error executing cl.exe.
Any Suggestions. Thank you.
Angel