Well, my last thread was getting too long and a bit confusing. So I decided to start a new thread and hopefully finalize my program.
I still am not getting the file with main() function to work. I think the stack.c file and the stack.h files are correct HOWEVER my main function file is not working. And it all has to do with the the test to see if the stack is full.
It maybe makes no sense to check this because as someone said (QuestionC) a linked list is never really full, but my instructor said that we are to let user input a string of text (however long) and the macro MAX_SIZE is to be set to 6 (why so short I haven't a clue -- go ask the stupid Professor with the PHd after his name !!) and then the result will be the text in reverse but only the last 6 characters, I guess. This is futile.
So I changed the code five times and keep coming up with wrong output. What the heck I am messing up? Please don't yell too loudly Quzah. I am a newbie that really is trying hard to get this syntax. I'd send you something for Xmas or Hanukkah but I don't know how to get it to you.
Code:
/********************/
/* stack_main.c */
/********************/
#include <stdio.h>
#include <stdlib.h>
#include "stack.h"
main()
{
char str[100];
int i;
make_empty(); /* call function to set 1st node to NULL */
printf("Please enter a line of text to be printed in reverse:");
/* getting character by character of input and then testing if
stack is full and then if not pushing another character and
incrementing through the text string till reach a carriage
return
/*
if (i<MAX_SIZE && (str[i] = getchar() != '\n')) {
if (!is_full())
push (str[i]);
i++;
}
/* while stack is not empty, pop out last character input, in
theory writing the text in reverse order
/*
while (!is_empty()) {
putc(pop(),stdout);
}
printf("\n");
return 0;
}