473,387 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Storing data structure

TDB
Hello,

I'm creating an application using C which requires the data structures
like trees and graphs to be stored in files and retrieved later
( simply serialization of a data structure ) .

Is there any libraries available in C for this purpose ?
Jan 27 '08 #1
9 2347
TDB wrote:
Hello,

I'm creating an application using C which requires the data structures
like trees and graphs to be stored in files and retrieved later
( simply serialization of a data structure ) .

Is there any libraries available in C for this purpose ?
The Standard library functions fread/fwrite should be sufficient
primitives for this purpose.

Jan 27 '08 #2
santosh said:
TDB wrote:
>Hello,

I'm creating an application using C which requires the data structures
like trees and graphs to be stored in files and retrieved later
( simply serialization of a data structure ) .

Is there any libraries available in C for this purpose ?

The Standard library functions fread/fwrite should be sufficient
primitives for this purpose.
You're right, but I don't think he was asking for primitives. He was asking
for a library which "understands" the serialisation of trees and graphs in
a way that primitives don't. You can't just fwrite(root, sizeof *root, 1,
fp) and expect the whole tree to be saved.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jan 27 '08 #3
TDB wrote:
Hello,

I'm creating an application using C which requires the data structures
like trees and graphs to be stored in files and retrieved later
( simply serialization of a data structure ) .

Is there any libraries available in C for this purpose ?
You will have to do that yourself, i.e. you will have to transform
the embedded pointers into pointers to other file structures.

In a very general form, you should be able to translate pointers into
indexes into a node array. When you read back the node array you
transform again those indexes into real pointers.

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Jan 27 '08 #4
santosh <sa*********@gmail.comwrites:
TDB wrote:
>I'm creating an application using C which requires the data structures
like trees and graphs to be stored in files and retrieved later
( simply serialization of a data structure ) .

Is there any libraries available in C for this purpose ?

The Standard library functions fread/fwrite should be sufficient
primitives for this purpose.
Certainly, but I think that misses the OP's point. You have to
flatten the data structure somehow, replacing any pointers with
something more "static" (not in the C keyword sense), before you can
fwrite anything.

I don't know of any libraries to do this, but they probably exist.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jan 27 '08 #5
TDB wrote:
) Hello,
)
) I'm creating an application using C which requires the data structures
) like trees and graphs to be stored in files and retrieved later
) ( simply serialization of a data structure ) .
)
) Is there any libraries available in C for this purpose ?

A library can only be expected to save a data structure in a file
if it knows all the details of that data structure, and this is usually
only the case if that library also provides those structures.
So, IMO your best bet would be to look for tree- and graph-libraries.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
Jan 27 '08 #6

"TDB" <vn*****@gmail.comwrote in message news
I'm creating an application using C which requires the data structures
like trees and graphs to be stored in files and retrieved later
( simply serialization of a data structure ) .

Is there any libraries available in C for this purpose ?
Yes and no.
One cannot store pointers in a file. Whilst there are general-purpose
libraries that purport to be able to serialise structures, using a
programmer-specified format string, these are so difficult to use that I
think it is red herring to recommend them.
However storing a tree is not too difficult. Simply write a bracket,
recursively write the subtree, and then write a closing bracket.

Loading is more tricky.
If you look for the Newick tree loader on my website you might find what you
are looking for. However it will only load trees, not graphs.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Jan 27 '08 #7
TDB wrote:
Hello,

I'm creating an application using C which requires the data structures
like trees and graphs to be stored in files and retrieved later
( simply serialization of a data structure ) .

Is there any libraries available in C for this purpose ?
One link I found through Google is:

<http://tpl.sourceforge.net/>

HTH

Jan 27 '08 #8
TDB <vn*****@gmail.comwrites:
Hello,

I'm creating an application using C which requires the data structures
like trees and graphs to be stored in files and retrieved later
( simply serialization of a data structure ) .

Is there any libraries available in C for this purpose ?
As others have pointed out without some work on your side this won't
work. Howerver you may check the berkeley DB stuff which offers quite
a bunch for "persitence in C"

http://www.oracle.com/database/berke.../db/index.html

Regards
Friedrich
--
Please remove just-for-news- to reply via e-mail.
Jan 27 '08 #9
Keith Thompson wrote:
santosh <sa*********@gmail.comwrites:
>TDB wrote:
>>I'm creating an application using C which requires the data
structures like trees and graphs to be stored in files and
retrieved later (simply serialization of a data structure).

Is there any libraries available in C for this purpose ?

The Standard library functions fread/fwrite should be
sufficient primitives for this purpose.

Certainly, but I think that misses the OP's point. You have to
flatten the data structure somehow, replacing any pointers with
something more "static" (not in the C keyword sense), before you
can fwrite anything.

I don't know of any libraries to do this, but they probably
exist.
Highly doubtful. Any such library would have to understand the
entire organization of the trees and graphs.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Jan 28 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Robert | last post by:
I have no problem storing dates + times in a System.DateTime object. In addition, it's easy to output a Time as a string from an existing Date/Time. But I'm having trouble storing a time only. ...
14
by: Dave | last post by:
Hello all, After perusing the Standard, I believe it is true to say that once you insert an element into a std::list<>, its location in memory never changes. This makes a std::list<> ideal for...
7
by: Dave | last post by:
I have a system that basically stores a database within a database (I'm sure lots have you have done this before in some form or another). At the end of the day, I'm storing the actual data...
15
by: Tor Erik Sønvisen | last post by:
Hi I need a time and space efficient way of storing up to 6 million bits. Time efficency is more important then space efficency as I'm going to do searches through the bit-set. regards tores
4
by: Hazzard | last post by:
What is the best way to do this? Binary with 0 representing off and 1 on? Int16 with 1 representing first button, 2 the second, 3 ... varchar with a character values at certain positions in the...
6
by: Kyle Teague | last post by:
What would give better performance, serializing a multidimensional array and storing it in a single entry in a table or storing each element of the array in a separate table and associating the...
1
by: rashmiharitas | last post by:
why are we storing object references varibles on stack data structure why not any other data structure please let me know about this
20
by: =?Utf-8?B?ZW1pdG9qbGV5ZXM=?= | last post by:
Hi everyone: i read from the documentation of a dll that there is a struct that uses char for storing an IP address. How can it be? and how come i can get to representate the same value in a...
6
by: Carl Banks | last post by:
I was wondering if anyone had any advice on this. This is not to study graph theory; I'm using the graph to represent a problem domain. The graphs could be arbitrarily large, and could easily...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.