Redefining an array

  • Thread starter Thread starter Mythran
  • Start date Start date
M

Mythran

man, it's been quite a long time since I was developing in C/C++ (GNU Linux
on RedHat 6.2 was last time I did)...

Anywho, I can't remember how to re-define/re-dimension an array.

Say I have an array of 30 characters...the first character is a space...I
want to remove this space...

OR

I have an array of 30 characters...there is one or more spaces SOMEWHERE in
the array and I want that element removed from the array, so there will be 1
or more elements removed from the array...

How would you do this? I know I can do it using 2 loops but is there
another way?


Thanks.

Mythran
 
Mythran said:
man, it's been quite a long time since I was developing in C/C++ (GNU Linux
on RedHat 6.2 was last time I did)...

Anywho, I can't remember how to re-define/re-dimension an array.

Say I have an array of 30 characters...the first character is a space...I
want to remove this space...
std::string::erase(0,1);

OR

I have an array of 30 characters...there is one or more spaces SOMEWHERE in
the array and I want that element removed from the array, so there will be 1
or more elements removed from the array...

How would you do this?

Without loops, std::remove (returns i) followed by an erase(i,end).

HTH,
Michiel Salters
 
Mythran said:
I have an array of 30 characters...there is one or more spaces SOMEWHERE in
the array and I want that element removed from the array, so there will be 1
or more elements removed from the array...

If you're using the .NET String, you can use its tring.Replace(String,
String)
passing " " and "". (ie a String with one space and the empty String)

HTH,
Michiel Salters
 
Back
Top