|
-
Mar 28th, 2012, 03:52 PM
#1
Thread Starter
Member
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);
}
-
Mar 29th, 2012, 06:21 AM
#2
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|