Two Letter Combinations | C++

February 18th, 2021 03:23:41 PM

					
#include <iostream> #include <fstream> #include <string> #include <cstring> using namespace std; //This program makes a new text file that contains all combinations of two letters. // aa, ab, ..., zy, zz int main(){ string filename = "two_letters.txt"; ofstream outFile; outFile.open(filename.c_str()); if(!outFile.is_open()){ cout << "Something's wrong. Closing..." << endl; return 0; } for(char first = 'a'; first <= 'z'; first++){ for(char second = 'a'; second <= 'z'; second++){ outFile << first << second << " "; } outFile << endl; } return 0; }

Featured Posts