Keep getting this error when running my program. If i remove either void function it works fine, but when i try to run the complete program it gives me the Expression: (unsigned)(c+1) <= 256 error. Tried a couple of threads in this site to figure out what's going on and still can't figure it out (Something, something unsigned character?). I'm a beginner so any help would be much appreciated. Here is what I have so far:
#include <fstream>
#include <iostream>
#include <cstdlib>
using namespace std;
void countUpperLower(ifstream& instream, ofstream& outstream);
void Convert(ifstream& in_stream, ofstream& out_stream);
int main()
{
ifstream fin;
ofstream fout;
fin.open("CAD.dat");
if (fin.fail())
{
cout << "Input file opening failed.\n";
exit(1);
}
fout.open("outputs.txt");
if (fout.fail())
{
cout << "Output file opening failed.\n";
exit(1);
}
countUpperLower(fin, fout);
Convert(fin, fout);
fin.close();
fout.close();
cout << endl << "End of editing files.\n";
return 0;
}
void countUpperLower(ifstream& instream, ofstream& outstream)
{
char caps;
int uppercase = 0;
int lowercase = 0;
do
{
instream.get(caps);
if (isupper(caps))
uppercase++;
else if (islower(caps))
lowercase++;
} while (caps != '.');
cout << "There are " << uppercase << " uppercase letters in this file\n";
cout << "There are " << lowercase << " lowercase letters in this file\n";
}
void Convert(ifstream& in_stream, ofstream& out_stream)
{
char next;
do
{
in_stream.get(next);
if (isspace(next))
cout << '-';
else if (isdigit(next))
cout << '#';
else if (isupper(next))
putchar (tolower(next));
else if (islower(next))
putchar (toupper(next));
else
cout << next;
} while (next != '.');
}