wait I think I get typedef StackNode *StackNodePtr; will be struct stackNode *StackNodePtr ? am I correct?
I've redone my code now look at the errors I really don't get it with this errors can anyone tell me ?
Code:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
struct stackNode
{
int data;
struct stackNode *nextPtr;
};
typedef struct stackNode StackNode;
typedef StackNode *StackNodePtr;
void instructions();
void push(StackNodePtr *, int value);
void print( StackNodePtr );
int main()
{
StackNode stackPtr = NULL;
int choice, value;
instructions();
do
{
scanf("%d",&choice);
system("cls");
if(choice == 1)
{
printf("Enter a value for the stac");
scanf("%d",&value);
push(&stackPtr,value);
printf( stackPtr );
}
if(choice == 2)
{
printf(" ");
}
if(choice == 3)
{
printf(" ");
}
if(choice == 4 )
{
printf("bye!");
return 0;
}
}while(choice !=4);
system("pause");
}
void instructions()
{
printf("[1]Push a value on the stack\n");
printf("[2]Pop a value off the stack\n");
printf("[3]Display the whole stack\n");
printf("[4]Exit");
}
void push (StackNodePtr *topPtr, int info)
{
StackNodePtr newPtr;
newPtr = (StackNodePtr)malloc(sizeof(StackNode));
if(newPtr !=NULL)
{
newPtr->data=info;
newPtr->nextPtr=*topPtr;
*topPtr = newPtr;
}
}
void print(StackNode Ptr current Ptr)
{
if(current == NULL)
printf("Stack Has No Entry");
else
{
printf("the stack is :\n");
while(currentPtr !=NULL)
{
printf("%d -->",currrent->data);
currentPtr = currentPtr->nextPtr;
}
}
}
I've redone my code now look at the errors I really don't get it with this errors can anyone tell me ?
Code:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
struct stackNode
{
int data;
struct stackNode *nextPtr;
};
typedef struct stackNode StackNode;
typedef StackNode *StackNodePtr;
void instructions();
void push(StackNodePtr *, int value);
void print( StackNodePtr );
int main()
{
StackNode stackPtr = NULL;
int choice, value;
instructions();
do
{
scanf("%d",&choice);
system("cls");
if(choice == 1)
{
printf("Enter a value for the stac");
scanf("%d",&value);
push(&stackPtr,value);
printf( stackPtr );
}
if(choice == 2)
{
printf(" ");
}
if(choice == 3)
{
printf(" ");
}
if(choice == 4 )
{
printf("bye!");
return 0;
}
}while(choice !=4);
system("pause");
}
void instructions()
{
printf("[1]Push a value on the stack\n");
printf("[2]Pop a value off the stack\n");
printf("[3]Display the whole stack\n");
printf("[4]Exit");
}
void push (StackNodePtr *topPtr, int info)
{
StackNodePtr newPtr;
newPtr = (StackNodePtr)malloc(sizeof(StackNode));
if(newPtr !=NULL)
{
newPtr->data=info;
newPtr->nextPtr=*topPtr;
*topPtr = newPtr;
}
}
void print(StackNode Ptr current Ptr)
{
if(current == NULL)
printf("Stack Has No Entry");
else
{
printf("the stack is :\n");
while(currentPtr !=NULL)
{
printf("%d -->",currrent->data);
currentPtr = currentPtr->nextPtr;
}
}
}