Created
October 14, 2014 17:48
-
-
Save LizardLeliel/5e612e02f4c9ae67a5bf to your computer and use it in GitHub Desktop.
A program that outputs its source code. The logic in this file is my own design; I didn't strictly follow code conventions for this exercise, hence the function named function.
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
#include <iostream> | |
#include <string> | |
using namespace std; | |
void function(string var, int flag); | |
int main(){ | |
function(R"!( | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
void function(string var, int flag); | |
int main(){)!", 1); | |
function(R"!( | |
return 0; | |
} | |
void function(string var, int flag){ | |
const string startFunction = R"#( | |
function(R"!()#"; | |
const string midFunction = { ')', '!', '"', ',', ' ', '\0' }; | |
const string endFunction = R"#();)#"; | |
if (flag == 1) { | |
cout << var; | |
cout << startFunction << var << midFunction << flag << endFunction; | |
} | |
else { | |
cout << startFunction << var << midFunction << flag << endFunction; | |
cout << var; | |
} | |
} | |
)!", 0); | |
return 0; | |
} | |
void function(string var, int flag){ | |
const string startFunction = R"#( | |
function(R"!()#"; | |
const string midFunction = { ')', '!', '"', ',', ' ', '\0' }; | |
const string endFunction = R"#();)#"; | |
if (flag == 1) { | |
cout << var; | |
cout << startFunction << var << midFunction << flag << endFunction; | |
} | |
else { | |
cout << startFunction << var << midFunction << flag << endFunction; | |
cout << var; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment