Debug Error!: Run-time check failure #2 - stack around variable 'infile' was corrupted.
weird info about this problem - the book says the file should be called RainOrShine.dat but my computer says its called RainOrShine.txt. I tried both... the .txt will cout some of the chars from file but then the error comes up. the .dat compiles and doesn't get an error but returns trash values for cout.
here is code:
Code:#include <iostream> #include <fstream> using namespace std; int main() { ifstream infile; infile.open("RainOrShine.txt"); char weather[3][30]; for (int i = 0; i < 3; i++) { for (int j = 0; i < 30; i++) { infile >> weather[i][j]; cout << weather[i][j]; } } infile.close(); return 0; }