| vicaddoil (1) | |
|
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!!!!! | |
|
|
|
| Armando Jenkins (4) | |
| I notice you've got a "col++", and then "col" is reassigned to 0 two lines later. Is there a reason for this? | |
|
|
|
| Cubbi (1927) | |||
Arrays can't be resized (they can only be recreated with a new size), use vectors:
| |||
|
|
|||