fork download
  1. #include <fstream>
  2. #include <ctime>
  3. #include <random>
  4.  
  5. #include "Dungeon.h"
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. srand(time(0));
  12. //setting file stream
  13. ofstream out;
  14. out.open("dungeon.txt");
  15. if(out.fail()){
  16. perror("dungeon.txt");
  17. return 1;
  18. }
  19.  
  20. //generating and initializing dungeon
  21. char **dungeon = new char*[D_HEIGHT];
  22. for (int i = 0; i < D_HEIGHT; i++)
  23. dungeon[i] = new char[D_WIDTH];
  24. Dungeon dung;
  25. dung.genDungeon(dungeon);
  26.  
  27. //print dungeon to the file
  28. for (int y = 0; y<D_HEIGHT; y++){
  29. for (int x = 0; x<D_WIDTH; x++){
  30. out << dungeon[y][x];
  31. }
  32. out << "\n";
  33. }
  34.  
  35. // De-Allocate memory to prevent memory leak and close the file
  36. for (int i = 0; i < D_HEIGHT; ++i)
  37. delete [] dungeon[i];
  38. delete [] dungeon;
  39. out.close();
  40.  
  41. return 0;
  42. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:5:21: fatal error: Dungeon.h: No such file or directory
 #include "Dungeon.h"
                     ^
compilation terminated.
stdout
Standard output is empty