it may help if i include my code =o):
Code:
#include <stdio.h>
int delete_element(int a[], int *n, int item, int loc); /*Define function and array*/
int g;
int main()
{
int cnt=0, a[20], *n, p, I;
while(*n<=20)
{
for (n=0; n<20; n++)
{
printf("Enter some integers (maximum of 20): \n");
scanf ( "%d", a[n] );
}
}
scanf("%d", &a[*n]);
if(cnt<=*n)
{
g = delete_element(a, n, cnt+1, cnt);
printf("\n");
if(g>1)
{
printf("Value %d: %d copies are deleted.", *n, g);
}
}
else
{
printf("Value %d: %d copy is deleted.", *n, g);
p=p+g;
}
cnt= cnt + 1;
printf("The resulting array is: \n");
for(I=0; I <=p; I ++)
{
printf("%d", a[I] );
}
return g;
}
int delete_element(int a[], int *n, int item, int loc);
{
int x, y, g=0, l;
for(x=loc; x<n; x=y)
{
y=x;
if(a[x]==item)
{
for(l=x; l<n-1; l++) a[l]=a[l+1];
g++; n--;
}
else y++;
}
return g;
}
Code tags once agian added by Kermi3