Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Remove(0,1) with tab characters

Reply
Thread Tools

Remove(0,1) with tab characters

 
 
Kamin of Ressik
Guest
Posts: n/a
 
      10-08-2012
I am using MS Visual Studio 2008 C++. Hopefully there is help here
because I cannot find anything useful at MSDN.

I am reading in a text based file with over 2000 lines. Each line has
a tab at the start and I need to remove it to then write to a new file.

I am using

array<String ^> ^lines =
System::IO::File::ReadAllLines(SourceSelector->FileName);

to read the file to an array.

Then this to strip away the tab:

lines[j]->Remove(0,1);

But nothing being removed. The string has been verified to be the same
after the coded executes with a breakpoint evaluation.

Is there something about the fact that it is a a tab character that is
making it fail to remove the character? I have even tried

lines[j]->Remove(5,3);

just to see if it works at all. Nothing is being stripped out of the
strings.


 
Reply With Quote
 
 
 
 
Kuroneko
Guest
Posts: n/a
 
      10-08-2012
On Monday, 8 October 2012 11:20:21 UTC-4, Kamin of Ressik wrote:
> I am using MS Visual Studio 2008 C++. Hopefully there is help here
>
> because I cannot find anything useful at MSDN.
>
>
>
> I am reading in a text based file with over 2000 lines. Each line has
>
> a tab at the start and I need to remove it to then write to a new file.
>
>
>
> I am using
>
>
>
> array<String ^> ^lines =
>
> System::IO::File::ReadAllLines(SourceSelector->FileName);
>
>
>
> to read the file to an array.
>
>
>
> Then this to strip away the tab:
>
>
>
> lines[j]->Remove(0,1);
>
>
>
> But nothing being removed. The string has been verified to be the same
>
> after the coded executes with a breakpoint evaluation.
>
>
>
> Is there something about the fact that it is a a tab character that is
>
> making it fail to remove the character? I have even tried
>
>
>
> lines[j]->Remove(5,3);
>
>
>
> just to see if it works at all. Nothing is being stripped out of the
>
> strings.


Are you assigning the value to lines[j]? Remove() returns a new string, but does not modify the old one.

Here: http://msdn.microsoft.com/en-us/library/d8d7z2kk.aspx
 
Reply With Quote
 
 
 
 
Tobias Müller
Guest
Posts: n/a
 
      10-08-2012
Kamin of Ressik <(E-Mail Removed)> wrote:
> I am using MS Visual Studio 2008 C++. Hopefully there is help here
> because I cannot find anything useful at MSDN.


First, you are not using plain C++, but C++/CLI, which is a Microsoft
Extension of C++. Many people here in this newsgroup even consider it a
different programming language.
C++/CLI is specifically made to run on the .NET platform. This means it's
very Microsoft specific and MSDN is indeed the right place to get your
information.
A quick google search for "string remove" points me directly to the correct
page.
Granted, the description is a bit misleading for .NET framework < 4.0, but
if you read the details page carefully you should nevertheless find the
solution.

> I am reading in a text based file with over 2000 lines. Each line has a
> tab at the start and I need to remove it to then write to a new file.
>
> I am using
>
> array<String ^> ^lines = System::IO::File::ReadAllLines(SourceSelector->FileName);
>
> to read the file to an array.
>
> Then this to strip away the tab:
>
> lines[j]->Remove(0,1);
>
> But nothing being removed. The string has been verified to be the same
> after the coded executes with a breakpoint evaluation.
>
> Is there something about the fact that it is a a tab character that is
> making it fail to remove the character? I have even tried
>
> lines[j]->Remove(5,3);
>
> just to see if it works at all. Nothing is being stripped out of the strings.


For Framework 4.0 the description is: "Returns a new string in which a
specified number of characters in this instance beginning at a specified
position have been deleted."

Additional hint: strings in .NET are generally immutable.

Just a little warning:
I wouldn't recommend C++/CLI at all. If you want to do serious .NET
programming, use C#.

Tobi
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Power Tab Editor - Guitar Tab Freeware TX harp Computer Support 1 03-05-2008 10:36 PM
How do I move from tab to tab? Bobby Firefox 11 12-21-2005 03:04 PM
Inserting a tab with tab completion enabled on win32 News Sympatico Python 0 05-21-2005 03:36 AM
Bug in Tabbrowser? (last tab always stays in tab list) Alexander Fischer Firefox 1 10-01-2004 07:40 AM
Re: URgent!!!!!!!!!!!! change tab selection Tab strip control Hermit Dave ASP .Net 0 01-22-2004 11:02 PM



Advertisments