Answers for "c++ list delete element at index"

C++
0

c++ remove item from list

// remove from list
#include <iostream>
#include <list>

int main ()
{
  int myints[]= {17,89,7,14};
  std::list<int> mylist (myints,myints+4);

  mylist.remove(89);

  std::cout << "mylist contains:";
  for (std::list<int>::iterator it=mylist.begin(); it!=mylist.end(); ++it)
    std::cout << ' ' << *it;
  std::cout << 'n';

  return 0;
}
Posted by: Guest on June-28-2020
0

delete custome index from array c++

const int SIZE = 9;
	int arr[SIZE];
	cout << "Enter numbers: n";
	for (int i = 0; i < SIZE; i++)
		cin >> arr[i];
	for (int i = 0; i < SIZE; i++)
		cout << arr[i] << "t";
	cout << endl;
	
	cout << "Enter Index U want to delete:n";
	int del;
	cin >> del;
	for (int i = del-1; i < SIZE; i++)
	{
		arr[del] = arr[del + 1];
		del++;
	}
	for (int i = 0; i < SIZE - 1; i++)
		cout << arr[i] << "t";
	cout << endl;
Posted by: Guest on January-12-2021
0

how to erase elemts accoding to index c++

arr.erase(arr.begin() + i);
Posted by: Guest on March-11-2021

Code answers related to "c++ list delete element at index"

Browse Popular Code Answers by Language