Deleting an array index using pointer

How can I delete an index of array using pointers?

Page 1 of 1

1 Replies - 5939 Views - Last Post: 07 November 2008 - 03:02 PM Rate Topic: -----

#1 jingoria   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 96
  • Joined: 22-October 07

Deleting an array index using pointer

Post icon  Posted 06 November 2008 - 12:47 AM

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.

This post has been edited by jingoria: 06 November 2008 - 12:51 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Deleting an array index using pointer

#2 jingoria   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 96
  • Joined: 22-October 07

Re: Deleting an array index using pointer

Posted 07 November 2008 - 03:02 PM

I don't know what icon to click on to show this thread is solved.

So I am just writting it .

[solved]
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1