I'm making this little text rpg game and i want to display this ascii as a death screen. I have made a c++ file that has that (i found the code online and i didn't want to put it in the main code just cause it'd be too long to place that whenever you die, it reads a .txt file with the ascii) and i need a way to execute it from the main cpp file when i run it. Is there a way? I have searched the web, but nothing i could clearly understand came out.
here's the code for the ascii if it helps:
#include <iostream>
#include <fstream>
#include <string>
std::string getFileContents (std::ifstream&); /*Gets filecontents*/
int main(int argc, char *argv[])
{
std::ifstream Reader ("ded.txt"); //Open file
std::string Art = getFileContents (Reader); //Get file
std::cout << Art << std::endl; //Print it to the screen
Reader.close (); //Close file
return 0;
}
std::string getFileContents (std::ifstream& File)
{
std::string Lines = ""; //All lines
if (File) //Check if everything is good
{
while (File.good ())
{
std::string TempLine; //Temp line
std::getline (File , TempLine); //Get temp line
TempLine += "\n"; //Add newline character
Lines += TempLine; //Add newline
}
return Lines;
}
else //Return error
{
return "ERROR File does not exist.";
}
}