Thread: STACK problem part II

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User sballew's Avatar
    Join Date
    Sep 2001
    Posts
    157

    STACK problem part II

    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;
    }
    Last edited by sballew; 11-30-2001 at 09:07 PM.
    Sue B.

    dazed and confused


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A problem in part of array.
    By dirtydrummer in forum C Programming
    Replies: 3
    Last Post: 04-01-2008, 02:04 AM
  2. Stack overflow errors in 3 areas
    By ulillillia in forum C Programming
    Replies: 13
    Last Post: 04-29-2007, 03:20 PM
  3. need help for stack problem again
    By bahareh in forum C++ Programming
    Replies: 20
    Last Post: 11-24-2006, 10:01 AM
  4. Stack functions as arrays instead of node pointers
    By sballew in forum C Programming
    Replies: 8
    Last Post: 12-04-2001, 11:13 AM
  5. Array Stack Problem
    By Drew in forum C++ Programming
    Replies: 3
    Last Post: 09-04-2001, 06:58 PM