Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Linked list in c <list.h> ?

Posted on 2003-11-22
5
Medium Priority
?
2,976 Views
Last Modified: 2013-12-14
Hi,
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?
Thanks,
Itsik
0
Comment
Question by:JavaInTheMorning
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 45

Expert Comment

by:sunnycoder
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
0
 
LVL 3

Author Comment

by:JavaInTheMorning
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?

Thanks,
Itsik
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 1000 total points
ID: 9803203

#include <list.h>

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

typedef list<int> INT_LIST;


INT_LIST list;

list.push_back(1);
list.push_back(2);
list.push_back(3);


INT_LIST::iterator theIterator;

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

list.clear();

0
 
LVL 17

Expert Comment

by:rstaveley
ID: 9804296
If you want to use Microsoft's CList, check out the COLLECT example at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample/html/_sample_mfc_COLLECT.asp. 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 :-)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

604 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