Thread: read data into stacks

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    15

    Talking read data into stacks

    Suppose I did not read the data directly into a stack, because I need to to through each character to decide if it's going to be print out or not.

    My idea is to read the chars in the array to the stack, and then do the processing where I can use stack.pop and cout to print out the chars (some will be reversed, some won't)

    My code looks something like this, but it would not do the stack.push from the very begining. Anyone knows why?

    ...


    Stack stack1;

    for (int i = 0; i <arraySize; i++)
    {
    //different states here

    switch (state)
    {

    case 1:

    if ( A[i] != '\"' )
    stack1.push(A[i]) //assertation is done in the the stack.h located outside
    ...


    }

    Thank you.

  2. #2
    Registered User Engineer's Avatar
    Join Date
    Oct 2001
    Posts
    125
    How about posting more of your code so its actually possible to find the problem, and not just guess about where the problem might be.
    1 rule of the Samurai Code: if you have nothing to say, don't say anything at all!

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    15
    Thank you, I've solved this problem.

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    42
    Wouldn't you be better using vectors


    Marky_Mark

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. "sorting news" assignment
    By prljavibluzer in forum C Programming
    Replies: 7
    Last Post: 02-06-2008, 06:45 AM
  2. read() is not reading the whole data
    By maven in forum C Programming
    Replies: 6
    Last Post: 02-18-2006, 07:15 AM
  3. Replies: 1
    Last Post: 09-10-2005, 06:02 AM
  4. read data from file
    By matth in forum C++ Programming
    Replies: 3
    Last Post: 04-21-2005, 09:37 AM
  5. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM