-
processing file?
Code:
this->input= reader->ReadLine();
String^ delimeter = ",";
int index = 0;
try{
Convert::ToDecimal(this->input->Substring(index,this->input->IndexOf(delimeter)));
if (withHeader) {
this->textBox1->AppendText("Time\t\t");
this->textBox1->AppendText("UserID\t");
this->textBox1->AppendText("Wireless Signal Status\n");
// Log the time stamp and user ID
}
//Seem to be having problems here
this->textBox1->AppendText(String::Concat(this->input->Substring(index,this->input->IndexOf(delimeter)),"\t\t"));input=this->input->Substring(this->input->IndexOf(delimeter)+1,this->input->Length-this->input->IndexOf(delimeter));
this->textBox1->AppendText(String::Concat(this->input->Substring(index,this->input->IndexOf(delimeter)),"\t"));input=this->input->Substring(this->input->IndexOf(delimeter)+1,this->input->Length-this->input->IndexOf(delimeter));
I'm trying to process a file that has the form
timestamp, userid...etc
12.13, 0, 1.....etc
It's correctly outputing the first of the substrings but then it goes to hell.
Anyone see what I'm doing wrong
-
String.Split Method (Char[]) (System)
Side note: In those examples it creates arrays to send to the functions you don't have to do that. You can just do:
Code:
string toSplitString = "100,200,300,400";
string[] splitStringArray = toSplitString.split(',');
-
I'm having trouble using split
Code:
std::string * stringArray;
std::string inputDelimeter;
stringArray=this->input->Split(gcnew Char [] {','});//error here
1>c:\users\ripspinner\documents\visual studio 2008\projects\lessonform\lessonform\Form1.h(682) : error C2440: 'initializing' : cannot convert from 'char' to 'wchar_t (*)[]'
std::string does not have a split method
input is a System::String^
and Split will not accept my delimeter
-
I fixed the one error but have another
Code:
std::string stringArray[];
std::string inputDelimeter;
stringArray=this->input->Split(',');//error with assignment type mismatch
1>c:\users\ripspinner\documents\visual studio 2008\projects\lessonform\lessonform\Form1.h(682) : error C2440: '=' : cannot convert from 'cli::array<Type,dimension> ^' to 'std::string []'
I also can't declare a string array like this std::string [] stringArray;
all the examples using split I have seen are in C# not C++
-
found the solution after a ton of searching
Code:
array<String^>^ stringArray;
stringArray=this->input->Split(',');