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 408665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:42:50+00:00 2026-05-12T17:42:50+00:00

I just started learning C++ couple of weeks ago. So now I have this

  • 0

I just started learning C++ couple of weeks ago. So now I have this school assignment problem that asks me to implement a linked-list without using “new” or anything to do with dynamically allocating memory (and cannot use any ADT from STL). The prof says that everything can be done on the stack, but how? I have been working on this since Friday and still stuck on this with absolutely no luck.

It says: Keep a stack of the file names being read. Use the following data structure for the stack:

struct Node { 
string fileName; 
Node *link; 
}; 

I tried to avoid using new but it always give me “segmentation fault” or “BUS error” when I pass the head of the list into a recursive method call. Any ideas about how I can work around this??

  • 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-05-12T17:42:50+00:00Added an answer on May 12, 2026 at 5:42 pm

    The difference between heap and stack are mainly (not only, but for the sake of this question mainly) where the memory is allocated and how it is freed. When you want to allocate a node on the heap, you say new Node and the system will provide you with the memory, keeps track of which chunks are used and which ones are free, and provides you with the means to free a chunk once you don’t need it any longer.

    But you can just as well have a pool of nodes in an array on the stack. (Automatic variables are stack variables.) You can “allocate” from that pool, keep track of which nodes in the array are used and which are free, and mark unused ones as free ones you don’t need them any longer. However, since the array’s size is fixed at compile-time, this means that you have a maximum length for your list.

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

Sidebar

Related Questions

I have just started learning XNA. This is my first program that I am
Just started learning PySide and is having problem with QTimer I have this #!/usr/bin/python
I am a beginner and just started learning Python couple days ago (yay!) so
Just started learning Haskell. I have an empty source file with this inside: pe
I just started learning SQL a couple of days ago, and I'm trying to
I just started learning about ASP.NET, and I have a couple of questions. Am
just started learning Assembler in school, and want to ask how to compile this
I just started learning C. What I am trying to right now is that
I've just started learning openGL a couple of hours ago for my work and
First I should say I only started learning HTML,PHP,Jquery a couple of weeks ago

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.