#include <iostream>
#include <cctype>
#include <fstream>
#include <cstdlib>
usingnamespace std;
int main(){
ifstream infile; // (ifstream) For the infile.fail
infile.open("/Users/ha/Desktop/Everything/Kishwaukee/CS 240/Program 6/Program 6/password.rtf");
if( infile.fail() ) //if the input file failed to open
{
cout << "input file did not open" << endl;
exit(1); //stop execution of the program immediately
}
int ch;
infile >> ch;
cout << "The number is: " << ch << endl;
infile.close();
return 0;
}
#include <iostream>
#include <fstream>
#include <string>
int main()
{
std::ifstream infile; // (ifstream) For the infile.fail
infile.open("/Users/ha/Desktop/Everything/Kishwaukee/CS 240/Program 6/Program 6/password.rtf");
if( infile.fail() ) //if the input file failed to open
{
std::cout << "input file did not open\n";
exit(1); //stop execution of the program immediately
}
std::string ch;
std::getline(infile, ch);
std::cout << "The number is: " << ch << "\n";
infile.close();
}