what wrong with my matrix file programing that print out~why i can not get result ~emergancy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip> 
#include <sstream>
using namespace std;


struct matrix
{
	double mat[30][30];
	int row;
	int col;
};

int main()
{
	char filename[500];
	matrix m;
	char s[256];
	ifstream inf;
	cin.getline(filename,500);
	inf.open(filename);	
	if(!inf)
	{	
		cout<<"fail to open file input.txt."<<endl;
	}
	else
	{	
		cout<<"file open successful."<<endl;
		cout<<"reading............"<<endl;
		if(!inf.eof())
		{
			for(int a=0;a<30;a++)
			{
				for(int b=0;b<30;b++)
				{
					inf>>m.mat[a][b];
				}
			}
			for(int a=0;a<30;a++)
			{
				for(int b=0;b<30;a++)
				{
					cout<<setw(3)<<m.mat[a][b];
				}
				cout<<endl;
			}
		}
	}
	inf.close();
  system("pause");
  return 0;
}
Topic archived. No new replies allowed.