Guest User

Untitled

a guest
Jan 21st, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. root@Ubuntu:~# cat ArrayCheck.cpp
  2. #include<iostream>
  3. using namespace std;
  4. int main() {
  5.     int *array = NULL, n, pos;
  6.     cout << "\nEnter size of array : ";
  7.     cin >> n;
  8.     array = new int[n];
  9.     for (int i = 0; i < n; i++) {
  10.         array[i] = i+1;
  11.     }
  12.     cout << "\nEnter the element to be deleted : ";
  13.     cin >> pos;
  14.     for (int i = pos-1; i < n-1; i++) {
  15.         array[i] = array[i+1];
  16.     }
  17.     delete array[pos-1];
  18.     return 0;
  19. }
  20. root@Ubuntu:~# g++ ArrayCheck.cpp -o ArrayCheck
  21. ArrayCheck.cpp: In function ‘int main():
  22. ArrayCheck.cpp:16:20: error: type ‘int’ argument given to ‘delete’, expected pointer
  23. root@Ubuntu:~#
Add Comment
Please, Sign In to add comment