Last active
July 12, 2018 06:50
-
-
Save luitzenhietkamp/834ca293d2663c2268aee1b4f730177e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple program that helps you format code for reddit | |
// put your code in a text file called "reddit_code.txt" | |
// and run the exe. | |
// You will now be able to find your indented source code | |
// back in "reddit_code.txt" from which you can straight | |
// up copy-paste your code into a reddit post. | |
// Make sure to leave a blank line around your code when | |
// you post on reddit. | |
#include <fstream> | |
#include <iostream> | |
#include <string> | |
int main() { | |
std::ifstream input_file("source_code.txt"); | |
std::ofstream output_file("reddit_code.txt"); | |
if(!input_file) { | |
std::cout << "Error: could not open \"source_code.txt\"\n\n" | |
<< "Enter some input (a character) and press the Enter-key to continue . . ." | |
<< std::endl; | |
char c; | |
std::cin >> c; | |
return 0; | |
} | |
std::string line; | |
while (getline(input_file, line)) | |
output_file << "\t" << line << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment