This program will write a series of letters, starting with 'A', to an external file (letters.txt). The user will decide how many letters in total get saved to the file.
** IMPORTANT: The test cases will evaluate your code against .txt files that I uploaded. You do NOT have to upload your own txt files.
Input:
Including 'A', how many total letters would you like to store? [user types: 26]
Output (in the file, not in the console window)
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
int count;
cout << "Including 'A', how many total letters would you like to store ?: ";
cin>> count;
ofstream of;
of.open("letters.txt");
if (!of.is_open())
cout << "File isn`t opened!";
else
{
for (int i = 0; i < count; i++)
{
of << char(65 + i) << " ";
}
}
}
Comments
Leave a comment