I need to write a program for my intro class that counts the characters in book i must be able to enter at least 3 books. I can get 1 but when it get to the second it cannot open..help!
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream in_stream;
ofstream out_stream;
int bookcnt=1;
int books;
int asciichar [223];
char letter;
char letters [100];
int cnt;
int value;
int lettercnt;
char book[50];
for (cnt=0;cnt<=223;cnt++)
{
asciichar[cnt]=0;
}
cout<<"How many books would you like to input?";
cin>>books;
while (bookcnt<=books)
{
cout<<"Enter file name of book "<<bookcnt<<":";
cin>>book;
in_stream.open(book);
if (in_stream.fail())
{
cout<<book<< " file could not be opened.\n";
exit (1);
}
while(in_stream)
{
in_stream>>letter;
value=letter;
asciichar[value]++;
}
bookcnt++;
}