DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   help with inserting a number into an array (http://www.daniweb.com/forums/thread17744.html)

Foxtildawn Jan 31st, 2005 12:01 am
help with inserting a number into an array
 
im trying to insert a number into an array but when i insert a number it deletes the last number instead of increasing the array size by one....this is the code i have:

void Insertion(float T[100],int size)
{
float target = 0.0;
cout<<"Enter the number you are inserting"<<endl;
outData<<"Enter the number you are inserting"<<endl;
cin>>target;

int k=0;
while((k< size) && (T[k] < target))
k++;
for(int index = size -1; index>=k;index --)
{
T[index + 1] = T[index];
}

T[k] = target;
size = size + 1;
}

Thanks

jwenting Jan 31st, 2005 4:07 am
Re: help with inserting a number into an array
 
arrays are fixed size...


All times are GMT -4. The time now is 7:44 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC