read the file and put it into a 2d array to later calculate some things! ive gotten the rest of the algorithm the only thing left is to import the file and convert the the numbers to ints and put them in the array so i can use them. this is all i got and i dont know where to go from there/
#include <fstream>
#include <iostream>
// Other headers
int main()
{
std::ifstream fin("test.txt");
int grid[5*5] // Array to hold grid. Single dimension.
if (!fin.is_open ()) // ALWAYS TEST IF FILE EXISTS
{
std::cout << "File not found. Check executable directory for the file.\n\n"return 1;
}
for (int i = 0; i < 25 && fin.good(); ++i) // Less than 25 elements, and ifstream is still good.
{
fin >> grid[i];
// Reads Left to right, top to bottom.
}
std::cout << "File Read." << std::endl;
}