String^ File = "C:\\Users\\**** :) secret ****\\Documents\\Error.txt"; StreamReader^ sr = File::OpenText(File); String^ str; bool Flip = true; int index = 0; while ((str = sr->ReadLine()) != nullptr) { // initiates a stringbuilder of 50 characters StringBuilder^ sb = gcnew StringBuilder("", 50); for(int i=0; i < str->Length; i++) {// for each char in line of string str if it is a digit or decimal place then... if(Char::IsDigit( str[i]) || str[i] == '.') sb->Append( str[i] ); // append to stringbuilder else { // otherwise convert the stringbuilder to a double number double Num = Convert::ToDouble( sb ); Flip = !Flip; // decides which 'side' of 2d array to place in if(!Flip) 2dArray[index, 0] = Num; // column 1 else 2dArray[index, 1] = Num; // column 2 // remove all elements of string clear for rest of line read. sb->Remove(0, sb->Length-1); } } index++; // increments for array index }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)