help with inserting a number into an array

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2005
Posts: 15
Reputation: Foxtildawn is an unknown quantity at this point 
Solved Threads: 0
Foxtildawn Foxtildawn is offline Offline
Newbie Poster

help with inserting a number into an array

 
0
  #1
Jan 31st, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,144
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: help with inserting a number into an array

 
0
  #2
Jan 31st, 2005
arrays are fixed size...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC