Thread: processing file?

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    20

    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

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    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(',');
    Woop?

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    20
    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

  4. #4
    Registered User
    Join Date
    Feb 2008
    Posts
    20
    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++

  5. #5
    Registered User
    Join Date
    Feb 2008
    Posts
    20
    found the solution after a ton of searching
    Code:
    array<String^>^ stringArray;
    stringArray=this->input->Split(',');

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File Writing Problem
    By polskash in forum C Programming
    Replies: 3
    Last Post: 02-13-2009, 10:47 AM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  4. file processing updating record error
    By uuser in forum C Programming
    Replies: 2
    Last Post: 04-27-2003, 12:13 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM