how to display a text file
i'm not going to post the entire code but i'll post the relevant part. the situation is i have a .txt file (input.txt), and the program reads that and counts the characters in it and displays the number of characters, spaces, digits, etc. but i also want it to display the actual text from the file. is there a way to have it display the file, without actually copying and pasting all of the text into the compiler?
so instead of cout<<"1000000 words"
cout<<input.txt
something like that.
so this is the first part of the code that opens the file. how do i make the program display the text when i run it?
Code:
#include <iomanip>
#include <iostream>
#include <fstream>
#include <ctype.h>
using namespace std;
bool myIsAlpha( char ch );
bool myIsDigit( char ch );
bool myIsUpper( char ch );
int countPunct = 0, //declaring int variables to be used.
countAlpha = 0,
countUp = 0,
countWhite=0,
countLow = 0,
countDig = 0,
countSpace = 0,
totalChar;
char ch; //declaring ch as char
int main()
{
ifstream inputFile;
//opening the input file and if it fails to open, displaying and error message to the user and exiting the program
inputFile.open( "input.txt" );
if( inputFile.fail() )
{
cout << "input.txt failed to open";
exit( -1 );
}