I am making a program where user can edit array. I am new in programming.code is not finished yet.
Can I use calloc(size-1,2)
? Is that valid ?
Does it creates array size-1
?
#include <stdlib.h>
#include <stdio.h>
int main()
{
int *pointer1,*pointer2,size,i,choice,j=0,index;
printf("Enter Elements of Arrays " );
scanf("%d",&size);
pointer1=(int*)calloc(size,2);
for(i=0;i!=size;i++){
scanf("%d",pointer1+i);
}
printf("Enter your choice \n" );
scanf("%d",&choice);
switch(choice)
{
case 0:
printf("Enter Index for Deletation ");
scanf("%d",&index);
/* I know that code is not finish. but calloc(size-1,2) is that valid or not ?*/
pointer2=(int*)calloc(size-1,2);
for(i=0;i!=size-1;i++){
if(i!=index){
*pointer2+i=*pointer1+i+j;
}
else{
j++;
}
}
for(i=0;i<=size;i++)
{
printf("\n%d",*pointer2+i);
}
break;
default:
printf("Error!");
}
return 0;
}