Linked list in c <list.h> ?

Posted on 2003-11-22
Last Modified: 2013-12-14
I want to use a linked list in c, and I saw that there's a file called list.h in the include of visual studio... Is that what I'm supposed to use? If so, can you please give me an example of how to do that?
Question by:JavaInTheMorning
LVL 45

Expert Comment

ID: 9802706
If this is you home assignment, you need to write everything on your own ... you cannot use the list.h that is already there ... I think it is C++ lib file ... so you cannot use it for a C programming assignment any way

Author Comment

ID: 9802728
This is a home assignment, but the point is not using a linked list, this is something I want to do... THe point is drawing something with OpenGL... I found out about CList, can anyone give me an example of using it?

LVL 48

Accepted Solution

AlexFM earned 250 total points
ID: 9803203

#include <list.h>

// or new-style header:
// #include <list>
// using namespace std;

typedef list<int> INT_LIST;

INT_LIST list;


INT_LIST::iterator theIterator;

for (theIterator = list.begin(); iterator != list.end(); theIterator++)
    printf("%d\n", *theIterator);


LVL 48

Expert Comment

ID: 9803216
LVL 17

Expert Comment

ID: 9804296
If you want to use Microsoft's CList, check out the COLLECT example at Be warned that this is MFC, which means that it is non-standard C++ and should be discussed at http:/Programming/Programming_Languages/MFC/ .

AlexFM's suggestion to use the STL containers is standard C++ and should be discussed at http:/Programming/Programming_Languages/Cplusplus/ . If it is neither here nor there to you, I'd go with AlexFM's suggestion.

Poor old vanilla C doesn't have containers in its libraries and non-specific requests for help in implementing linked lists in C usually get followed up by accusations of homework cheating.... and quite rightly so :-)

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sameEnds challenge 3 180
Raspberry Pi 3 to send text message 9 149
How to access ANSI/IEEE Std 754 or equivalent information ? 3 73
Windows Server 2012  Backup - HyperV host 18 59
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question