fork(1) download
  1. #include <cstdlib>
  2. #include <fstream>
  3. #include <iostream>
  4. #include <string>
  5. #include <vector>
  6. #include <conio.h>
  7.  
  8.  
  9.  
  10. int main() {
  11. std::vector<std::string> maze;
  12. std::ifstream file("maze2.txt");
  13. for (std::string line; std::getline(file, line);) {
  14. maze.push_back(line); }
  15. file.close();
  16. int row = 1, column = 1;
  17. int rowd = 2, columnd = 2;
  18. while (true) {
  19. std::vector<std::string> board = maze;
  20. board[row][column] = '&';
  21. /////////////////////////////////
  22. for (std::string line: board) {
  23. std::cout << line << std::endl; }
  24. char key = getch();
  25.  
  26. std::system("cls");
  27. switch (key) {
  28. case 's': {
  29. if (maze[row + 1][column] == ' ') {
  30. ++row; }
  31. break; }
  32. case 'w': {
  33. if (maze[row - 1][column] == ' ') {
  34. --row; }
  35. break; }
  36. case 'd': {
  37. if (maze[row][column + 1] == ' ') {
  38. ++column; }
  39. break; }
  40. case 'a': {
  41. if (maze[row][column - 1] == ' ') {
  42. --column; }
  43. break; }}
  44.  
  45. //////////////////////////
  46. board[rowd][columnd] = '!';
  47.  
  48. for (std::string line: board) {
  49. std::cout << line << std::endl; }
  50. char keys = getch();
  51.  
  52. std::system("cls");
  53. switch (keys) {
  54. case 'k': {
  55. if (maze[rowd + 1][columnd] == ' ') {
  56. ++rowd; }
  57. break; }
  58. case 'i': {
  59. if (maze[rowd - 1][columnd] == ' ') {
  60. --rowd; }
  61. break; }
  62. case 'l': {
  63. if (maze[rowd][columnd + 1] == ' ') {
  64. ++columnd; }
  65. break; }
  66. case 'j': {
  67. if (maze[rowd][columnd - 1] == ' ') {
  68. --columnd; }
  69.  
  70. break; }}
  71.  
  72.  
  73.  
  74. }}
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:6:10: fatal error: conio.h: No such file or directory
 #include <conio.h>
          ^~~~~~~~~
compilation terminated.
stdout
Standard output is empty