Hi guys, being a beginner I have some trouble with pointers. I don't know but something about using pointers is just not getting clear to me.
My assignment requires that from an array of given values, the user inputs a particular integer whose every occurrence with in the array should be deleted and the size of the array should then be reduced respectively. I tried but I am not getting how can I accomplish this with a pointer.
Here is the my code:
// HW5_Bhasin.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
using namespace std;
void Erase(int [], int* ,int* );
int main()
{
char choice;
const int max = 5;
int a[max];
int itemCount=0, SearchElement=0;
cout<<"Please select from the following menu."<<endl;
cout<<" E(Erase Array Content)\tC(Count Words)\tR(Reverse Words)\tQ(Quit)"<<endl;
cin>> choice;
cin.ignore();
switch(choice)
case 'E':
case 'e':
Erase(a, &itemCount, &SearchElement);
return 0;
}
void Erase( int ar[], int *item, int *Search)// this function is suppose to delete every occurrence of the digit input by the user.the item is suppose to keep the count of the array size search is the item to be deleted.
{
int digit;
cout<<"Please enter the number whose all occurrence needs to be deleted."<<endl;
cin<< digit;
Search = &digit;
cout<<"Erase this number"<<endl;
return;
}
Thanks.