the problem is that, the function is only replacing the number that I want to delete with th number after it, but everything remains the same after.
e.g.
it is showing me
1 2 3 5 5 6 7 8 9 10

#include <stdio.h>
int rem(int a[],int pLen,int pos)
   {
 int count;
 for (count = pos;count < pLen;count++)
  {
   a[count] = a[count+1];
   return a[count];
  }
   }
main()
{
 int arr[10] = {1,2,3,4,5,6,7,8,9,10};
 int count2;
 rem(arr,10,3);
 for (count2 = 0;count2 <= 9;count2++)
  {
   printf(" %d ",arr[count2]);
  }
 getch();
}

>> return a[count];
the above is inside the loop, so the loop only runs once.

thanks a lot!
and how do I get rid of the last number please? since it then is showing me two 10 at the end?

you can't actually delete it. you can set it to 0 if you wish, but it will still be there. What you can do is decement the variable that contains the number of elements in the array. Just pretend the array only has 9 elements insead of 10.

Oh ok, so I will reduce the number of times that the loop will run so as not to print the second 10. Really thanks a lot now it works :)!!

Member Avatar for nicentral

Are you trying to reduce the size of the array afterwards? It looks as if you are trying to reproduce the functionality of a vector or linked list. You migt want to take a look at those instead.

-- Andy

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.