Resize my array

Hi I'm new in C++ so anybody can help me of resizing my array?
I want to read a txt file and store it in an array:
//Load polygon points
string data[30][3];
int icol, irow, row=0,col=0,vertixNo,testPtsNo;
string line;
ifstream infile("D:/00-Temp/21points.dat");
if(infile.is_open()){
while(!infile.eof()){
getline(infile,line);
stringstream ss(line);
while(ss>>data[row][col])
col++;
icol=col-1;
col=0;
row++;
}
irow=row-1;
vertixNo = row-1;
infile.close();
In fact there are only 21 points so can I change the size of 'data[30][3]' according to 'vertixNo'? Or any other suggestions to make this code more professional? XD

Many thanks!!!!!
I notice you've got a "col++", and then "col" is reassigned to 0 two lines later. Is there a reason for this?
Arrays can't be resized (they can only be recreated with a new size), use vectors:

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
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    ifstream infile("D:/00-Temp/21points.dat");

    vector< vector<string> > data;

    string line;
    while(getline(infile,line))
    {   
        vector<string> row;
        stringstream ss(line);
        string word;
        while( ss >> word )
        {   
            row.push_back(word);
        }
        data.push_back(row);
    }
Topic archived. No new replies allowed.