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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:32:55+00:00 2026-05-11T05:32:55+00:00

I am writing a program in c++ which implements a doubly-linked list that holds

  • 0

I am writing a program in c++ which implements a doubly-linked list that holds a single character in each node. I am inserting characters via the append function:

doubly_linked_list adam; adam.append('a'); 

This function is implemented as follows:

//Append node     node* append(const item c){          //If the list is not empty...         if(length){             //maintain pointers to end nodes             node* old_last_node = last;             node* new_last_node = new node;              //re-assign the double link and exit link             old_last_node->next = new_last_node;             new_last_node->back = old_last_node;             new_last_node->next = NULL;              //re-assign the last pointer             last = new_last_node;         }         //If this is the first node         else{             //assign first and last to the new node             last = first = new node;              //assign nulls to the pointers on new node             first->next = first->back = NULL;         }          //increase length and exit         ++length;         return last;     } 

However, I think there is an issue, perhaps with the way C++ handles characters. When I go to print my list, somehow I never get the characters to print which I have appended to my list. This is what I’m using to print:

//Friendly output function     friend std::ostream& operator << (std::ostream& out_s, const doubly_linked_list& source_list){         //create iteration node pointer         node* traverse_position = source_list.first;          //iterate through, reading from start         for(int i = 1; i <= source_list.length; ++i){             //print the character             out_s << (traverse_position->data);             traverse_position = traverse_position->next;         }          //return the output stream         return out_s;     } 

I just get crap when I print it. It prints characters that I never appended to my list – you know, just characters just from somewhere in the memory. What could possibly be causing 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. 2026-05-11T05:32:55+00:00Added an answer on May 11, 2026 at 5:32 am

    Where are you assigning the value c in the append() function? I fear you may have concentrated too much on the doubly-linked-list part and not enough on the storing-data part. 🙂

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

Sidebar

Related Questions

I'm writing a program that has an NSView embedded in an NSScrollView which user
I'm writing a program that implements the Boneh-Franklin Identity Based Encryption. For the actual
I am writing a program which has two panes (via CSplitter ), however I
I am writing a C# program which captures signals from a external device, and
I wrote a program which includes writing and reading from database. When I run
In the python program I'm writing, I've got a thread which iterates over a
im writing an application that downloads and installs addons for programs which needs to
I'm writing a program that sends an email out at a client's specific local
If you are writing a program that is executable from the command line, you
I'm writing a program which takes filenames and options on the command line in

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.