hi all,
i need to read coordinate from a .txt file to draw lines , here is the example of the file

1E20,   1E20,   1               
154.0872,3703.414,1955          
178.458,3719.069,1955
239.8909,3753.263,1955
1E20,   1E20,   2               
2480.712,105.5662,1950
2486.905,144.5641,1950
2512.991,215.5622,1950

lines 1 to 4 is line 1 coordinate
lines 5 to 8 is line 2 coordinate
separated by comma : X,Y,line info

what i'm asking is how to read each variable, and then use from each variable (X,Y)to draw a lines using

Dim pen As New Pen(Color.FromArgb(255, 0, 0, 0))
e.Graphics.DrawLine(pen, X1, Y1, X2, Y2)

thanks for your attention, sorry for bad english^^

hi,
thanks for the reply, but i think with getline(<istream>,<buff>,<delimiter>) i will only get one variable? or am i wrong?
when i look to msdn documentation there is example from getline, it use space as delimiter, and when it read "test this" it will only read "test"
so how it will read "test" and "this" as different variable value?

sorry for taking so long ^^
here is my code, thanks @nbaztec for help

Graphics^ g = e->Graphics;
ifstream infile;
float array[3000];
int i=0;
int d=1;

char cNum[10] ;
infile.open ("File.txt", ifstream::in);
if (infile.is_open())
{
   while (infile.good())
{
   infile.getline(cNum, 256, ',');
   array[i]= atoi(cNum) ;
   i++ ;
}
infile.close();
}
   else
{
   MessageBox::Show("Error Loading Data ","ERROR",MessageBoxButtons::OK,MessageBoxIcon::Error);
}

for(int zz=0;zz<(i-4);zz=zz+3){			
	if(array[zz+2]==d)		
		d++;
	else if (array[zz+5]==d)
		d=d;
	else {
		g->DrawLine( System::Drawing::Pens::Red, array[zz]/2*skala-hScrollBar2->Value,array[zz+1]/2*skala-vScrollBar1->Value,array[zz+3]/2*skala-hScrollBar2->Value,array[zz+4]/2*skala-vScrollBar1->Value);	
			
	}
}
This article has been dead for over six months. Start a new discussion instead.