Advertisement
shywolf91

Game of Life code

Feb 24th, 2012
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. //Game of Life
  2. //Dylan Metz
  3.  
  4. #include <iostream>
  5. #include <string>
  6. #include <fstream>
  7. #include <cstring>
  8.  
  9. using namespace std;
  10.  
  11. //function(s)
  12. void GetFile(); //Get filename
  13. char MakeArray(); //Make 2d array
  14. char ChgArray(); //change the array
  15. char GameBoard(); //Game Board
  16. //Global Variables
  17. const int ROW1 =12;
  18. const int COL1 =30;
  19. ifstream myfile;
  20. string filename;
  21. char live = 'x';
  22. char dead = '.';
  23. char name [ROW1][COL1];
  24. //end of Global variables
  25. int main()
  26. {
  27. int q; //stops terminal window from quitting   
  28. //call functions
  29. GetFile();
  30. MakeArray();
  31. ChgArray();
  32.  
  33. //Stop Program from quitting   
  34. cin >> q;  
  35.    
  36. return 0;
  37. }
  38.  
  39. //Other Functions
  40. void GetFile()
  41. {
  42. cout<<"Enter the filename: \n";
  43. cin>>filename;
  44. return;
  45. }
  46.  
  47. char MakeArray()
  48. {
  49. myfile.open (filename.c_str());
  50. for (int r=0; r<12; r++)
  51. {
  52.     for (int c=0; c<30; c++)
  53.      {
  54.        myfile>>name[r][c];
  55.         //cout << name[r][c];
  56.       }
  57. //cout << endl;
  58. }
  59. }
  60. char ChgArray()
  61. {
  62. char name2 [12][30];
  63. for (int r=0; r<12; r++)
  64. {
  65.     for (int c=0; c<30; c++)
  66.     {
  67.        name2[r][c]=name[r][c];
  68. //cout<<name2[r][c];
  69.         }
  70.         //cout<<endl;  
  71. }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement