-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfakeQuine.cpp
More file actions
32 lines (30 loc) · 946 Bytes
/
fakeQuine.cpp
File metadata and controls
32 lines (30 loc) · 946 Bytes
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
31
32
#include <fstream> //For ifstream
#include <sstream> //string lies here
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#define EXIT_FAILURE 1
int main(int argc, char const *argv[])
{
//In this case we're considering, there's not another way to do it, that the .cpp and the executable have the same
//and that they're in the same folder
std::string fileName = argv[0], line;
fileName+=".cpp";
std::ifstream file(fileName.c_str());
if(!file.is_open())
exit(EXIT_FAILURE);
//While there's something to read we will keep reading and showing it
while(std::getline(file, line)){
std::cout<<line<<"\n";
}
if (system(NULL))
puts ("Ok");
else
exit (EXIT_FAILURE);
//When we're sure that the system is ready to help us out to compile the game, we build the command string to excecute
std::stringstream command;
command<<"g++ -g "<<fileName<<" -o sample";
//And we run it
system(command.str().c_str());
return 0;
}