![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
|
C data structures lib?
Hey all, just a quick question...does C standard library provide a developer with basic data structures such as stacks, lists or trees? etc... and if it does, which header files should i include in order to use them? I googled for the answer, but all results were pointing to implementations which haven't been standardized. Thanks in advance.
|
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Oct 2006
Posts: 311
Rep Power: 3
![]() |
I'm fairly sure that isn't the case. In C, a linked list is a structure with a pointer link pointing to the next structure in the list. Stacks and Queues are possible implementations of linked lists.
|
|
|
|
|
|
#3 |
|
Programmer
|
So what you are saying is that every C programmer needs to implement his/her own data structures? I mean in many cases this is required as some date structures are particular to a given project or assigment, but something as common as a linked list?. That is pretty strange to me. It is not that im too lazy to implement my own, but it would be nice to have a well tested lib. at hand when needed you know.
|
|
|
|
|
|
#4 |
|
Professional Programmer
Join Date: Oct 2005
Location: Chitown
Posts: 422
Rep Power: 4
![]() |
I thought you were asking if data structures were part of a standard library.
|
|
|
|
|
|
#5 |
|
Programmer
|
There are plenty of libraries available, but you are correct in thinking that nothing is standardized.
|
|
|
|
|
|
#6 |
|
Programmer
|
This makes some things clearer, thanks all for your replies.
|
|
|
|
|
|
#7 |
|
SEXY SHOELESS GOD OF WAR!
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,198
Rep Power: 5
![]() |
C++, on the other hand, does have the Standard Template Library, which offers much of this functionality.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
|
#8 |
|
Unverified User
Join Date: Jul 2007
Location: England
Posts: 22
Rep Power: 0
![]() |
>C++, on the other hand, does have the Standard Template Library, which offers much of this functionality.
Problem with that is to use it, even if you stick to the C subset of C++, you need a good understanding of C++. I am not saying your suggestion is not valid, its exactly what I was thinking. If the OP can only use C then C++ is not an option. The OP is obviously worried about non-standard libraries. The problem with C is that its standard library is small in scope. Personally I just roll my own array list and linked list, they are not very hard to implement if you keep them simple. I have not made them into a library, all I usually do is just import the .c and .h files into my projects of my standard linked list. Stacks and queues can be easily adapted from those two data structures. Its actually quite fun to write your own data structures, though if you are new to C it can be a daunting but very educational exercise. |
|
|
|
|
|
#9 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
C is not strictly a subset of C++. There are perfectly valid C statements that will fail in C++. No understanding of C++ will allow one to take advantage of things like the STL when using C.
I'm not proposing that this is what you were saying, but it sounded like it.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#10 |
|
Unverified User
Join Date: Jul 2007
Location: England
Posts: 22
Rep Power: 0
![]() |
>C is not strictly a subset of C++
Yes I know, keywords like restrict are in C99 but not in ISO C++ etc. >No understanding of C++ will allow one to take advantage of things like the STL when using C. So your saying if you do not understand how new and delete work or what references are or how templates function you can just jump in and use the STL? >I'm not proposing that this is what you were saying, but it sounded like it. Yes I am saying that unless you know some C++ it is not easy just to jump in and use the STL with great success. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Data structures | Mr M | C++ | 2 | Jan 21st, 2007 9:30 PM |
| Arrays in data structures | d_heyzie | C++ | 4 | Apr 16th, 2006 10:01 AM |
| please help. hierarchical data structures. | vitroblue | C++ | 5 | Jun 26th, 2005 3:13 PM |
| Help in QBASIC (I think it's similar to VB) | phoenix987 | Visual Basic | 3 | May 9th, 2005 1:33 PM |
| Help with a QBASIC program | phoenix987 | Other Programming Languages | 4 | May 5th, 2005 1:27 PM |