Help With Array!

I am having problems with getting this array to compile to read from an input file. I have no clue where i messed up at. Any help will be apreciated.

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
  #include <iostream>
#include <fstream>
#include <sstream>
#include <cmath>
#include <ctime>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <algorithm>

using namespace std;


///
/// Main Function
///

int main(){
    fstream input_file;    ///< Input file stream
    string input_filename; ///< Input file name
    double perimeter = 0;  ///< Area of the polygon
    double area      = 0;  ///< Perimeter of the polygon
    double temp = 0;
    double points = 0;
    //prompt for input filename
    cout << "Enter the input filename: ";
    getline( cin, input_filename );


    //open input file
    input_file.open( input_filename.c_str(), ios::in );

    //Validate the filestream
    if( input_file.fail() ){
        cerr << "Input file is invalid.\n";
        return 1;
    }

    //Your code starts here
    double pointer [4][2];          //array for pointer


    for( int i = 0; i < 4; i++){
        for( int j = 0; j < 2; j++){
            points [i][j] = 0;

        }
        }
    input_file >> points [i][0]
               >> points [i][1];
What are you trying to accomplish with this?
1
2
   input_file >> points [i][0]
               >> points [i][1];


points is not an array, so it cannot be used with [] operator. Also, the i in square brakets hints that it belongs inside the loop, but is left outside.
Last edited on
Topic archived. No new replies allowed.