String Output Source [bored]

Don't really know where to post this but I was just bored and wrote it up so I felt like sharing. Basically it asks for a string input and converts it so it looks like a triangle wall of text. I saw someone make a post like this on a message board so felt like making a program out of it to pass some time.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
#include <fstream>
#include <string>

void ConvertMyString(std::string);

int main()
{
	std::string myString;
	std::cout << "Please enter a string to convert: ";
	std::getline(std::cin, myString);

	ConvertMyString(myString);
	system("pause");

	return 0;
}

void ConvertMyString(std::string myString)
{
	std::ofstream myFile;
	myFile.open("String Output.txt");
	for (int i = myString.length() - 1; i >= 0; i--)
	{
		std::cout << myString << std::endl;
		myFile << myString << std::endl;
		myString.erase(i, 1);
	}
	myFile.close();
}
Last edited on
Topic archived. No new replies allowed.