944,216 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3616
  • C++ RSS
Jan 31st, 2005
0

help with inserting a number into an array

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Foxtildawn is offline Offline
15 posts
since Jan 2005
Jan 31st, 2005
0

Re: help with inserting a number into an array

arrays are fixed size...
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: transfer input.txt to output.txt help prz
Next Thread in C++ Forum Timeline: Insert a number in an array





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC