I keep getting an error when using option 2. Could someone please point me in the right direction.

#include <iostream>


using namespace std;
	
	int num;
	int Size;
	int choice;
	int *currentArray = 0;
	int *tempArray = 0;
	int index, oldSize, newSize;
	
	struct nodeType
	{
		int info;
		nodeType *Link;
	};
	nodeType *Head, *current, *newNode;
	
	void PUSH(int num)
	{  
		newNode = new nodeType;
		newNode->info = num;
		newNode->Link = NULL;
		newNode->Link = Head;
		Head = newNode;
		newNode = NULL;
	}
	
	void POP(int num)
	{
		current = Head;
		current->Link = current->Link->Link;
		Head->Link = NULL;
		newNode = NULL;
	}

	int main()
{

	while(choice != 3)
	{

	cout<<"Press 1 to PUSH and 2 to POP and 3 is to exit";
	cout<<"\n";
	cin>>choice;
	

	Size = 0;

	if(choice ==1)
	{
		PUSH(num);
		Size = Size +1;
		cout<<"you have"<<"\n\n"<<Size<<"slots in your array"<<"\n\n";
		
	}

	if(choice ==2)
	{
		POP(num);
		Size = Size -1;
		cout<<"you have"<<"\n\n"<<Size<<"slots in your array"<<"\n\n";
		

	}

}
	}

Line 24.25. is kind of the same?

I you pop you need to release memory and check if you are and the end or will will get an segv. And if you are in C++ a class would just cool.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.