Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9318733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:12:14+00:00 2026-06-19T03:12:14+00:00

I completely understand what a stack is supposed to do (last in, first out).

  • 0

I completely understand what a stack is supposed to do (last in, first out). It’s just one part of the stack that gets me confused.

typedef struct dynArrStruct
{
    char *location; //element
    int length;  //max size
    int currSize; //top
}dynArr;


dynArr a; //declared in main
//sorry this is an assignment and I try to refrain from posting my full code
//on here b/c of potential cheaters

I use this code as my stack.

Basically my program is supposed to find balanced characters: ‘{‘, ‘(‘,'<‘, ‘[‘ and their closing counter parts.

In a nutshell, everytime I find an opening brace, I push it onto the stack. I keep pushing it onto the stack until I find a closing brace and as soon as I find a closing brace I need to pop the stack.

What I’m getting confused is with the variable char* location.

Let’s say my string is “()”

In GDB:

If I read in ‘(‘ I push it onto the stack.. and if I read in ‘)’ I pop it.

When I do: p a->location it prints out “()”

I’m just wondering am I supposed to be deleting “()” from the value of a->location everytime I pop a stack or is popping the stack irrelevant to a->location?

In other words should it print out “” after it has been popped?

I apologize ahead of time if this question doesn’t make sense

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T03:12:16+00:00Added an answer on June 19, 2026 at 3:12 am

    Since you haven’t posted your code it’s hard to be sure, but I suspect you are confusing a pointer (e.g. char * location) with the contents it is pointing to. A pointer currently pointing to a string “()” will print out as () in gdb, but the character pointed to (top of stack) would be just ‘(‘.

    It will be easier to be more specific if you post at least part of your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This was a 2 part assignment. first I had to figure out how to
I understand(not completely why, though) that instances of primitive types such as int, float
After working 15 years in C++ I found that I don't understand references completely.
I'm reading the not so complete pytz documentation and I'm stuck on understand one
Please help me with this update query. I COMPLETELY understand how redundant this is
I found some old code which I'm not sure I understand completely. The folowing
Clarification: I'm referring to companies that pay developers, professionally. I understand why a hobby
Once in a while, at random intervals, our website gets completely paralyzed. Looking at
Just when I thought I've understood this topic completely, I'm back to basics. I
I don't completely understand how javascript works in an OOP model, so I come

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.