--------------------------------------------------------------------------------
ID: 3532981 • Letter: #
Question
--------------------------------------------------------------------------------------
Thank you in advance for the help
This progam has some compiler errors five fixes should be enough to get it working This program reads an input file and counts the number of capitalized letters. That is, it will do so after you run it Once you get it to compile, check it with this: ./a. out alphabet. txt #include iostream> #include SCtype for the isupper. function using name space std; int main (int argc, char* argv ifstream, inf (argv [1]); Skip error checking for simplified t esting purposes char ch inf ch Get the first character while (!inf.eof Continue to end-of-file if (isupper.(ch)) count++; inf ch cout count endl inf closeExplanation / Answer
#include <iostream>
#include <cctype>
#include <fstream>
using std::ifstream;
using namespace std;
char* argy[] = {"alphabet.txt"};
int main()
{
int count = 0;
ifstream inf("textfile.txt");
char ch;
inf >> ch;
while( !inf.eof())
{
if (isupper(ch))
count++;
inf >> ch;
}
cout << count << endl;
inf.close();
system("pause"); //Take out this line. This pauses the program to show you it works.
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.