on-internet
← Community

C++ seg fault when printing matrix in file

Stack Overflow ·

so I'm working a little code that takes values from a file and stores them in a matrix in the code and make changes to the last row of the matrix, afterwards I'm trying to wipe the existing contents of the file and rewrite the matrix as a single column of values but I keep getting Segmentation fault (core dumped). At first I thought the code was only keeping the first row of values and deleting the rest but that's not it. Does anyone know what I can do? using namespace std; int main(){ int pass[3][3]; ifstream f("Usrs.txt"); if(f.fail()){ cout<<"Error: Can't open file.\n"; exit(1); } for(int i

Comments

Sign in or sign up to comment and upvote.

No comments yet.