Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- root@Ubuntu:~# cat ArrayCheck.cpp
- #include<iostream>
- using namespace std;
- int main() {
- int *array = NULL, n, pos;
- cout << "\nEnter size of array : ";
- cin >> n;
- array = new int[n];
- for (int i = 0; i < n; i++) {
- array[i] = i+1;
- }
- cout << "\nEnter the element to be deleted : ";
- cin >> pos;
- for (int i = pos-1; i < n-1; i++) {
- array[i] = array[i+1];
- }
- delete array[n-1];
- return 0;
- }
- root@Ubuntu:~# g++ ArrayCheck.cpp -o ArrayCheck
- ArrayCheck.cpp: In function ‘int main()’:
- ArrayCheck.cpp:16:20: error: type ‘int’ argument given to ‘delete’, expected pointer
- root@Ubuntu:~#
Add Comment
Please, Sign In to add comment