I am quite confused and will get more info later if things are different than how I explain here....

but....

first I need a stack.c file that contains all stack processing functions and a node pointer (first) and an integer counter (count).

second I need a stacka.c file that contains all the above functions but based on arrays instead of pointer.

then I need to write program that uses either of these above created stack files and will allow user to input a line of text and uses a stack to print line in reverse order.

Here's my questions:

(1) how do I change the stack.c file below to allow text to be input instead of integer values??? I know I would change in the structure the int data; to a char variable, but I don't understand how to change the rest of the functions to work properly (guess: I have to name a char variable and everywhere the word data shows up, change to that variable name AND get rid of the switch statement and just ask user for input ,,, but how do I utilize the POP and PUSH functions then???)

(2) how do you convert the structure pointer(s) to array(s)?? And have work just the same as with a pointer??

(3) What are the make_empty, is_empty, and is_full functions for?? I am guessing they are for a fully running program to find if the array string is full and if so won't allow more text to be printed out or taken in AND find if the array string is empty AND make the string empty at first and then ask the user to input text to be evaluated in the stack functions.


Here is my main function file
Code:
/********************/
/*  stack_mn.c      */
/********************/

#include <stdio.h>
#include <stdlib.h>
#include "stack.h"

main()
{
  int number, choice;

  for( ; ; )    {

    printf("\nChoose one of the following.\n\n"
           "0   To end program\n"
           "1   To add a value to list (Push)\n"
           "2   To remove top value from list (Pop)\n"
           "3   To print list \n"
           "4   To list # of nodes\n\n");

    printf("Enter your choice: ");
    scanf("%d", &choice);
    printf("\n");

    switch(choice)
    {
      case 0:
        printf("You have ended the program.\n"
               "Good-bye !! \n\n");
        exit(0);

      case 1:
        printf("Enter a number to push: ");
        scanf("%d", &number);
        push(number);
        break;

      case 2:
        number = pop();
        printf("You just removed %d\n", number);
        break;

      case 3:
        print_list();
        break;

      case 4:
        printf("You have %d nodes in your list\n",count);
        break;

      default:
        printf("Illegal choice.\n");
    }
  }
  return 0;
}

Here is the stack.c file with all functions for stack implementation defined
This is what I need help with ******

Code:
/*****************/
/*  stack.c      */
/****************/

#include <stdlib.h>
#include "stack.h"

#define MAX 6

struct node {

   int data;  
   struct node * next;
};

struct node *first = NULL;

void make_empty(void)
{
   first = NULL;
   count = 0;
}

int is_empty(void)
{
   return count == 0;
}

int is_full(void)
{
   return count == MAX;
}

void push(int insert_value)
{
   struct node *new_node;

   new_node=malloc(sizeof(struct node));
   if (new_node == NULL)  {
      printf("Error in push:  stack is full.\n");
      exit (EXIT_FAILURE);
   }
   new_node->data = insert_value;
   new_node->next = first;
   first = new_node;
   count++;
}

int pop(void)
{
  struct node * old_first;
  int i;

  if (is_empty())  {
     printf("Error in pop: stack is empty.\n");
     exit (EXIT_FAILURE);
  }

  printf("%d deleted successfully.\n",first->data);
  old_first=first;
  i = first->data;
  first = first->next;
  free(old_first);
  count--;
  return i;
}

void print_list()
{
  struct node *ptr;
  if (first == NULL) {
    printf("List is empty.\n\n");
  }

  else  {
       printf("\n\nHere is your list:  \n");
       for (ptr=first;ptr;ptr=ptr->next)
           printf("%d\n",ptr->data);
       return;
  }
}

Here is the header file for the stack


Code:
/********************/
/*  stack.h         */
/********************/

#include <stdlib.h>

#ifndef STACK_H
#define STACK_H

void make_empty(void);
int is_empty(void);
int is_full(void);
void push(int insert_value);
int pop(void);
void print_list();

int count;

#endif