By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,234 Members | 2,075 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,234 IT Pros & Developers. It's quick & easy.

Stacks

P: 6
Is it possible to creat a linked list of structs?
If so how would this be done?

Advanced thanks
Matt
Jun 3 '07 #1
Share this Question
Share on Google+
2 Replies


Savage
Expert 100+
P: 1,764
Is it possible to creat a linked list of structs?
If so how would this be done?

Advanced thanks
Matt
Yes it is possible.

U will need to first creare a struct and then another struct that will have previos struct and a pointer to a next element.

e.g

Telephone book:

First struct:

Expand|Select|Wrap|Line Numbers
  1. typedef struct data{
  2.  
  3.              string first name,lastname,city,telephone1,telephone2...
  4.  
  5. }TUser;
Secound struct:

Expand|Select|Wrap|Line Numbers
  1. typedef struct node{
  2.  
  3.                         TUser info;
  4.                         struct node *next;
  5. }TNode
Savage
Jun 3 '07 #2

weaknessforcats
Expert Mod 5K+
P: 9,197
Locate the book "Teach Yourself Data Structures in 24 Hours".

Failing that, locate "Algorithms in C++" by Robert Sedgewick.

Failing that, locate "The Art of Computer Programming" by Donald Knuth.
Jun 3 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.