Sup.
The basics of the program is that:
It will ask the user whether they want to: Pop, Push , Peek or Exit the program. When it comes to the Exit case:
I can't figure out how do so( tried exit(1) & exit(0) using the internet hasn't brought me much luck either. Maybe a forum will
I am getting these two errors also, without any idea how to fix it.
"Error LNK2019 : Unresolved external symbol "int_cdcel peek(void)" (?peek@@YAHXZ)"
Each applying to the functions below.
"Error LNK1120: 3 Unresolved Externals"
I'm not sure their is much more I can say about the problem.
Hopefully that is more then enough to go on.
Thankies
Carl
[code is below!]
Code:
#include "stdafx.h"#include <stdio.h>
/* Libary Collection.*/
#define MAX 10
/* Define: The max size of what we are working with.*/
int push (void);
int pop(void);
int peek (void);
/* Declaring the three global functions to be used in the program.*/
int _tmain(int argc, _TCHAR* argv[])
{
int stack[MAX];
int top = 0;
int ch; /* Choice variable for switch statement*/
do
{
printf("\n\n\n\n1.\tPush\n2.\tPop\n3.\tDisplay\n4.\tExit\n");
printf("\nEnter your choice: ");
scanf_s("%d", &ch);
/* Above prints out the users choices & prompts & scan for the users input and following accordingly*/
switch(ch)
{
case 1:
push();
break;
case 2:
pop();
break;
case 3:
peek();
break;
case 4:
// I need to set case 4 : to exit the program: However, I can't figure out how too.
break;
default:
printf("\n\nInvalid entry. Please try again...\n");
}
} while(ch!=4);
getchar();
}
/* I have 4 other errors on the program:
"Error LNK2019 : Unresolved external symbol "int_cdcel peek(void)" (?peek@@YAHXZ)"
Each applying to the functions below.
&&
"Error LNK1120: 3 Unresolved Externals"
/* Three functions created: Peek, Push & Pop*/
int pop(int &top, int stack[])
{
if(top > 0)
{
top--;
return stack[top];
}
else
{
return -1;
}
}
int push(int &top, int stack[], int value)
{
if(top < MAX)
{
stack[top] = value;
top++;
return 1;
}
else
{
return 0;
}
}
int peek(int top, int stack[])
{
return stack[top];
}
Edit: I was also told that I could us if statements instead but, that still will remove the first errors