inserting object into array

I need some help, below is a insert function that inserts a number into a array. It inserts correctly but deletes the number at the inserted index, can you give me a hint on stopping it from deleting the number at the index, and instead moving it down one index?
arr before calling function insertit:
1
2
3
4
5
6
arr after calling function insertit:
1
2
3
3333
4
5
6


1
2
3
4
5
6
7
8
9
10
11
12
int insertit(int x[100], int c, int in, int v) {
	int co=0;
	co=x[in];
    for ( int i=0; i<c; i++ ){
        if ( i==in ){
            x[i] = v;
			x[i+1]=co;
			
        }
    }
 return 0;
}
First move all elements from "c" to "in" up. Iterate downwards so that you don't overwrite anything. The code inside the loop is x[i+1] = x[i];;
When you do that, just x[in]=v;
Thanks for the help, your solution worked.
i am doing sort of the same thing but mine keeps deleting as well ...i read wut u suggested but i am still doing sumthing wrong......can you post the whole code for the function......i cannot seem to get it to stop deleting......thnx
Topic archived. No new replies allowed.