0
in fedora tell me the program for deletion of an array on c++
7 odpowiedzi
+ 1
first of all weather you be in fedora or linux or Mac or Windows the code wont change much
and then
what type of deletion are you talking about....
I mean deletion of element in an array
or
deletion of an array
+ 1
You cannot delete a single element in a array, you have to recreate the array with one number less and then copy the contents of the old array to the new array.
Or you can use std::vector in vector header.
0
If the array is dynamically created(using a pointer) you should use delete[] nameOfArray;
If it was a static array(dont confuse with static keyword) the array is removed from memory when it goes out of scope.
0
deletion of an element in an array
0
plz give the whole program syntax
0
//try this
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int i,inputarray[10],no,pos;
cout<<"Enter 10 data elements in array: ";
for(i=0;i<10;i++)
{
cin>>inputarray[i];
}
cout<<"\nEnter position of element to delete: ";
cin>>pos;
if(pos>10)
{
cout<<"\n position value is not in range: ";
}
else
{
--pos;
for(i=pos;i<=9;i++)
{
inputarray[i]=inputarray[i+1];
}
cout<<"\n\nNew data in array: ";
for(i=0;i<9;i++)
{
cout<<inputarray[i];
cout<<" ";
}
}
}
//actually I just made it here so you'll need to
//eliminate syntax errors, if any
0
thank you