Thread: Splitting text

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

    Splitting text

    I'm trying to split a text from a text file into token strings but I really have no clue

    Code:
    if ( (openFileDialog1->OpenFile()) != nullptr ){
         this->filename = openFileDialog1->SafeFileName;
         this->reader = gcnew System::IO::StreamReader(filename);
         this->textBox1->Text="";
         std::string * input_array;
         do
    	{
                	this->input= reader->ReadLine();
    		String^ delimeter = ",";
    		foreach(delimeter in input)
    			{
    				input_array = input->Split(delimeter);
    			}
    		}  
         while(reader->Peek() != -1);
    }     
     this->reader->Close();this->reader=nullptr;
    Here are the errors
    1>------ Build started: Project: LessonForm, Configuration: Debug Win32 ------
    1>Compiling...
    1>cl : Command line warning D9025 : overriding '/clrure' with '/clr'
    1>LessonForm.cpp
    1>c:\users\ripspinner\documents\visual studio 2008\projects\lessonform\lessonform\Form1.h(678) : error C2146: syntax error : missing ')' before identifier 'in'
    1>c:\users\ripspinner\documents\visual studio 2008\projects\lessonform\lessonform\Form1.h(678) : error C2059: syntax error : ')'
    1>c:\users\ripspinner\documents\visual studio 2008\projects\lessonform\lessonform\Form1.h(679) : error C2143: syntax error : missing ';' before '{'
    1>c:\users\ripspinner\documents\visual studio 2008\projects\lessonform\lessonform\Form1.h(680) : error C2664: 'cli::array<Type,dimension> ^System::String::Split(...cli::array<wchar_t,1> ^)' : cannot convert parameter 1 from 'System::String ^' to 'wchar_t'
    1> with
    1> [
    1> Type=System::String ^,
    1> dimension=1
    1> ]
    1> No user-defined-conversion operator available, or
    1> There is no context in which this conversion is possible
    1>c:\users\ripspinner\documents\visual studio 2008\projects\lessonform\lessonform\Form1.h(678) : error C3861: 'foreach': identifier not found
    1>Build log was saved at "file://c:\Users\ripspinner\Documents\Visual Studio 2008\Projects\LessonForm\LessonForm\Debug\BuildLog .htm"
    1>LessonForm - 5 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  2. #2
    Registered User
    Join Date
    Feb 2008
    Posts
    20
    I figured out a solution
    Code:
    if ( (openFileDialog1->OpenFile()) != nullptr ){
    					 this->filename = openFileDialog1->SafeFileName;
    					this->reader = gcnew System::IO::StreamReader(filename);
    					this->textBox1->Text="";
    					System::String^ split;
    					do
    					{
    						this->input= reader->ReadLine();
    						String^ delimeter = ",";
    						int start_index = 0;
    						for (int index = this->input->IndexOf(delimeter, start_index); this->input->LastIndexOf(delimeter); index ++)
    								{
    									split = this->input->Substring(index,this->input->IndexOf(delimeter));
    								}
    					}   
    					while(reader->Peek() != -1);
    				}
    				 this->reader->Close();this->reader=nullptr;
    
    			  }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deleting Text from a Text file
    By Daved in forum C++ Programming
    Replies: 5
    Last Post: 11-04-2006, 09:47 PM
  2. Having trouble drawing text xlib.
    By Qui in forum Linux Programming
    Replies: 1
    Last Post: 05-10-2006, 12:07 PM
  3. Appending text to an edit control
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 08-13-2004, 09:52 PM
  4. Scrolling The Text
    By GaPe in forum C Programming
    Replies: 3
    Last Post: 07-14-2002, 04:33 PM
  5. Replies: 1
    Last Post: 07-13-2002, 05:45 PM