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

  • Home
  • SEARCH
  • 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 4022918
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:32:08+00:00 2026-05-20T10:32:08+00:00

void display() { list *newlist; newlist = first; cout << endl; do { if

  • 0
void display()


  {  

     list *newlist;

     newlist = first;

     cout << endl;

     do
      {
       if (newlist == NULL)
       cout << "List is empty" << endl;
       else
       {
          cout << "Name is: " << newlist->name << " ";
          cout << "Age is: " << newlist->age << " ";
          cout << "Height is: " << newlist->height;
          if (newlist==current)
          cout<<" <-- Current position ";
          cout<< endl;
          newlist = newlist->next;
       }
      }
    while(newlist!=NULL);
    cout << "End of List" << endl;
  }

I corrected my whole code with the help from here about the current initialization i love this site !
Just this one problem
I want to show the Cursor at the current node only.
But this code doesn’t even show the “<–current position” written.
When I cut out the “if(newlist==current)”
the “<–current position” appeared for all the nodes.
So Im a bit confused as to where I should be placing this…
Also I have to insert a node between other nodes.
Can someone show me a code on how to show the “current position” wherever I move current or wherever the current is pointing at ?

  • 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-20T10:32:08+00:00Added an answer on May 20, 2026 at 10:32 am

    Mahis, in your previous post I corrected your source code. Please read the comments in the code I provided. This will answer your question. See here.

    You may have initialized your current to NULL, but when you add an element, you also need to set current to the correct value. For example, when you insert the first value in your linked list, current = first. The problem now is that you are comparing newlist to NULL, which will never evaluate to true. And so it will never print your current position.

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

Sidebar

Related Questions

public void test() { List<int> list = new List<int>(); list.Add(1); list.Add(2); list.Add(3); for (int
. private void Form1_Load(object sender, EventArgs e) { List<CaclulatedData> tests = new List<CaclulatedData> {
public static void main(String[] args) { List<? extends Object> mylist = new ArrayList<Object>(); mylist.add(Java);
Okay, so I want to display a list containing lists of lists of lists...
void (int a[]) { a[5] = 3; // this is wrong? } Can I
void addNewNode (struct node *head, int n) { struct node* temp = (struct node*)
void some_func(int param = get_default_param_value());
void foo(void **Pointer); int main () { int *IntPtr; foo(&((void*)IntPtr)); } Why do I
private void activateRecords(long[] stuff) { ... api.activateRecords(Arrays.asList(specIdsToActivate)); } Shouldn't this call to Arrays.asList return
typedef void (FunctionSet::* Function)(); class MyFunctionSet : public FunctionSet { protected: void addFunctions() {

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.