473,396 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Redefining an array

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
Nov 17 '05 #1
3 1237
Hello Mythran,

I recommend using vectors from STL.

- Bio

"Mythran" wrote:
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

Nov 17 '05 #2


"Mythran" wrote:
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
Nov 17 '05 #3
"Mythran" wrote:
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
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brian | last post by:
I'm diddlying with a script, and found some behavior I don't understand. Take this snippet: for ($i = 0; $i <= count($m); $i++) { array_shift($m); reset($m); }
2
by: Stormkid | last post by:
Hi Group I'm trying to figure out a way that I can take two (two dimensional) arrays and avShed and shed, and subtract the matching elements in shed from avShed I've pasted the arrays blow from a...
15
by: lawrence | last post by:
I wanted to test xml_parse_into_struct() so I took the example off of www.php.net and put this code up on a site: <?php $simple = <<<END <item>
1
by: Xiangliang Meng | last post by:
Hi, all. When reading C++ books, I'm alway confused by those terms "redefining functions", "overloading functions" and "overriding functions". Please give me some comments on those terms....
7
by: bberu | last post by:
Hi, I know it is possible to refine operators (like +, -, * or /) on classes. But is it possible on simple types ? ex : If I have a type like : typedef int vector is it possible to redefine a...
3
by: notme | last post by:
I have code with lots of "new int..." etc.. I'd like to replace every instance with "new(allocInfo) int" (that is, using placement new) I tried doing: #define new (new(allocInfo)) but that...
4
by: allan.mcrae | last post by:
As part of a very simple memory leak detector, I am trying to store the value of __FILE__ in a char*. Since gcc4.2 I get the following warning... warning: deprecated conversion from string...
4
by: Belebele | last post by:
The following code fails to compile. My intention is to provide different definitions for a nested class for a class template partial specialization. Here it is: template <typename , int class...
2
by: rolan | last post by:
I'm trying to figure out how to convert an array of type "string" into integers, and I have begun using istringstream. I made a program to test how istringstream works, and I've been having...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.