how to delete element from array c
for (int i = pos; i < size; i++)
{
arr[i-1]= arr[i];
}
how to delete element from array c
for (int i = pos; i < size; i++)
{
arr[i-1]= arr[i];
}
delete string function in c
/*The logic behind the function is to copy and place the ending part of string
along with the deliminator '\0' to the position from where you want the
"no_of_char" number of characters removed*/
void delchar(char *string,int starting_pos, int no_of_char)
{
if (( starting_pos + no_of_char - 1 ) <= strlen(x) )
{
strcpy(&x[starting_pos-1],&x[starting_pos + no_of_char-1]);
puts(x);
}
}
delete a number in array in c
#include<stdio.h>
void main()
{
int a[10], del_num, i, n, pos;
printf("Enter number of elements in array: ");
scanf("%d", &n);
for(i = 0; i < n; i++)
{
printf("Enter %d number: ",i+1);
scanf("%d", &a[i]);
}
printf("\n\nThe input array is: ");
for(i = 0; i < n; i++)
{
printf("%d ", a[i]);
}
printf("\n\nEnter the number to be deleted: ");
scanf("%d", &del_num);
for(i = 0; i < n; i++)
{
if(a[i] == del_num)
{
a[i]=0;
}
}
printf("\n\nResultant array is: ");
for(i = 0; i < n; i++)
{
printf("%d ",a[i]);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us