Results 1 to 2 of 2

Thread: print link list

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2012
    Posts
    35

    print link list

    what is the error here ???


    // linkme.cpp : Defines the entry point for the console application.
    //

    #include "stdafx.h"
    #include <iostream>
    using namespace std;
    double val;
    struct node {
    typedef double item;
    item data; // data stored in node
    node *link; //pointer to next node
    };


    int _tmain(int argc, _TCHAR* argv[])
    {

    node *head_ptr;
    node *tail_ptr;
    node *insert_ptr;
    node *print_ptr;
    head_ptr=NULL;
    tail_ptr=NULL;
    insert_ptr=NULL;

    cout << "Give Initial Value" <<endl ;
    cin >> val;
    insert_ptr = new node;
    insert_ptr ->data=val; //vali to stixio tis listas sto proto kouti pou ekama
    head_ptr = insert_ptr; // kamni point sto insert_ptr
    tail_ptr = insert_ptr; //kamni to idio
    insert_ptr =NULL; //Kamnoto null gia na figi



    while ( val<100)
    {
    cout << "Give Value" <<endl ;
    cin >> val;
    insert_ptr = new node;
    insert_ptr ->data=val;
    insert_ptr = head_ptr;
    head_ptr = insert_ptr;
    insert_ptr = NULL;
    };
    print_ptr=head_ptr->link;

    while ( print_ptr !=NULL)
    {
    cout << print_ptr->data;
    print_ptr=print_ptr->link;
    }
    return(0);

    }

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: print link list

    You tell us. Is there a runtime error when you execute the code? Or are you just not getting the expected results? You have to make an effort to describe your problem.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width