Computing.Net > Forums > Programming > c++ help on dynamic arrays

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

c++ help on dynamic arrays

Reply to Message Icon

Name: jc
Date: March 4, 2003 at 03:36:19 Pacific
OS: windows 98
CPU/Ram: 128
Comment:

hi, i am a beginner and trying to learn how dynamic arrays works, i have the function here but having troubles on implementing them on main, pls help me

//.............
int FindItemIndex(const vector Array, const String Goal)
/*Returns the inxed of the first occurrence of Goal in Array, or -1 if Goal not in List.
Post: The index of the first occurence of Goal in Array returned, or -1 returned if Goal not in
Array*/
{
for (int i = 0; i &Array,const String &ValToAdd)
/*Incresase size of Array by 1 and ads ValToAdd to ARray
as the last element
Post: Array length increased by 1 and ValToAdd is last element of array*/
{
Array.resize(Array.length()+1);
Array[Array.length()-1]= ValToAdd;
}
//...................
void RemoveFromArray(vector &Array, const String &ValToDelete)
/*Deletes ValToDelete from ARray and decreases size of Array by 1 Pre: ARray is of size >= 1
Post: Array length has decreased by 1 and VAlToDelte is removed */
{
int Index = FindItemIndex (Array, ValToDelete);
or (;IndexArray.length()-1;Index++)
Array[Index]= Array[Index+1];
Array.resize(Array.length()-1);
}
//..............



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


C++ Stucts & Function... hardware serial interface



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: c++ help on dynamic arrays

C++ Dynamic Array www.computing.net/answers/programming/c-dynamic-array/11481.html

Dynamic Arrays in C www.computing.net/answers/programming/dynamic-arrays-in-c/3396.html

C++ Dynamic arrays sparse matrix? www.computing.net/answers/programming/c-dynamic-arrays-sparse-matrix-/11530.html