problems using a txt file and Array

Hi, so im trying to use array to access data in a txt file. Each value in the row corresponds to a different value. This is the data in the txt file..

1
2
3
4
5
6
7
8
9
10
11
12
C14 14 8 0.4 16 2.0 1.7 
C16 16 10 0.5 17 2.2 1.8 
C18 18 11 0.5 18 2.2 2.0 
C20 20 12 0.5 19 2.4 2.2 
C22 22 13 0.5 20 2.5 2.4 
C24 24 14 0.5 21 2.6 2.5 
C27 27 16 0.6 22 2.6 2.8 
C30 30 18 0.6 23 2.7 3.0 
C35 35 21 0.6 25 2.8 3.4 
C40 40 24 0.6 26 2.9 3.8 
C45 45 27 0.6 27 3.1 3.8 
C50 50 30 0.6 29 3.2 3.8


and this is what i have in my program so far. (note i have only started doing to for C14)...

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
#include<iostream>
#include<cmath>
#include<math.h>
#include<fstream>
#include<string>

using namespace std;

void timber_type()
{
	float bending_strength, tension_parallel, tension_perpendicular,compression_parallel, compression_perpendicular, shear;
	int timber_class;

	cout<<"Please input type of soft timber (C14, C16, C18, C20, C22, C24, C27, C30, C35, C40, C45, C50). "
	<<"(Enter value and press enter.)"<<endl;
	cout<<"C";
	cin>>timber_class;

			ifstream myfile;
			myfile.open("TextFile1.txt");
				
			string array[7][12];
				
	myfile>>array[7][1];
		while (timber_class==14)
		{	
			ifstream myfile;
			myfile.open("TextFile1.txt");
				
			string array[7][12];
			myfile>>array[7][12];
			int a=0;
			int b=0;

			cout<<"Timber class selected:"<<array[0][0]<<endl;
			cout<<"bending strength:"<<array[1][0]<<endl;
			cout<<"tension parallel:"<<array[2][0]<<endl;
			cout<<"tension perpendicular:"<<array[3][0]<<endl;
			cout<<"compression parallel:"<<array[4][0]<<endl;
			cout<<"compression perpendicular:"<<array[5][0]<<endl;
			cout<<"shear:"<<array[6][0]<<endl;
			break;
			}
		if (timber_class!=14)
			{
				cout<<"ERROR"<<endl;
			}	
	
}


When i run the program no values are outputted. I know i must be doing something wrong but not sure what. I am extremely new to C++ (only been using for a week or so). Please need help on this!

Oh and just to make sure after array it is [colum][row] (as i have done above) right?
you seem to be missing int main()
Hi, sorry i havent copied the whole code, only the section i has having difficulty with. Below is my int main(). Any ideas as to what the problem could be? The program does run however does not output any data from the txt file.

1
2
3
4
5
6
7
8
9
int main()
{
	dimensions();
	area();
	static_load();
	variable_load();
	design_load();
	timber_type();
}
Topic archived. No new replies allowed.