LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-27-2012, 11:45 PM   #1
jman82s
Member
 
Registered: Jul 2007
Location: Central Coast, California
Distribution: "distro-hopper"
Posts: 66

Rep: Reputation: 15
(lack of) Simple Data Structures in C


Hello all,

I'm an older, 'junior-ish' senior CS student, about to begin taking some heavy C courses. My school teaches Java as introductory courses, and while I've had a couple low-level courses (ASM, digital logic, brief intro to C), I really haven't had much experience with C. I've been reading up on Kernighan and Ritchie's C book ("The C Book"), did a ctrl+f on "linked list," didn't find much. Did some e-sleuthing, and it appears you need to create a linked linked list from scratch (and I assume the same follows for other common higher-level data structures, like maps, trees, et al.)

I may have missed something, but have these complex data structures been built in to any free, standard libraries, er?? I understand the nature of C, and that it's low-level, got the pointers, and the structs-as-opposed-to-classes, but....I have trouble believing headers/libs don't exist for creating these.

Thanks!
 
Old 10-28-2012, 02:47 AM   #2
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 852

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Hi,
I don't know of any libraries that provide these structures for C. I think you really need to write those from scratch. More over, if you have list of, say, ints and a list of floats, you'll either have to implement the list (or whatever) structure for both these types separately, or do some nasty things with typecasting or maybe some ugly macros. That's probably one of the good reasons to use C++ instead. You don't lose anything - you can still write procedural code just like in C if you wish, almost anything you can do in C is valid in C++ too, but in addition, you get some nice features like templates and function overloading, which will make your life much easier. Also, the standard C++ STL library contains a lot of useful structures such as lists, vectors, maps, queues etc that will work with practically any type.
Hope this helps
 
1 members found this post helpful.
Old 10-28-2012, 03:25 AM   #3
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
The most common one is GLib, and it's probably already installed:
http://developer.gnome.org/glib/stable/

There are others too:
http://www.gnu.org/software/gnulib/
http://sglib.sourceforge.net/
http://home.gna.org/gdsl/

Search the net for more.
 
2 members found this post helpful.
Old 10-28-2012, 06:56 PM   #4
jman82s
Member
 
Registered: Jul 2007
Location: Central Coast, California
Distribution: "distro-hopper"
Posts: 66

Original Poster
Rep: Reputation: 15
Thanks for the info, guys. I definitely plan to use C++ whenever possible as I understand the libraries do have support for these higher-level structures (as you confirmed, millgates). Many thanks also for the link to the GLib page, TexMex. So that's what those glibc packages I've been seeing for years are all about. Should come in handy in the future!
 
Old 10-28-2012, 11:25 PM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
In unix, there is a search.h, implementing queue, tree and hashmap

Last edited by NevemTeve; 10-28-2012 at 11:27 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
from kernel data structures ? sha_neb Linux - Kernel 1 06-08-2007 03:54 PM
Problem with Data Structures in C kalamaraki Programming 3 10-29-2006 09:48 AM
Problem - A simple C program using Structures manishsingh4u Programming 6 05-15-2006 03:55 AM
kernel data structures vishalbutte Programming 8 01-05-2006 03:19 PM
java data structures tunedLow Programming 4 12-17-2002 11:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration