LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 03-17-2006, 01:52 PM   #1
Pratik H Pandya
LQ Newbie
 
Registered: Jun 2005
Location: India
Distribution: RedHat 9.0,Fedora core 3
Posts: 22

Rep: Reputation: 15
dumping a structure into a file


Hello friends,

again one silly question, how i can dump all the data members of task_struct structure into a file?? as the structure itself is very big and moreover its most of members are also pointers to other structure so what can be done in this case?? plz help me


thanx in advanvce,

-Pratik H Pandya.
 
Old 03-17-2006, 03:11 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
If you are wanting to follow the pointers then you will need to write a function that will dump the details for you.
 
Old 03-17-2006, 03:16 PM   #3
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
My previous answer is assuming that the program is in C or C++, many other languages come with constructs to help you with the particular problem you are describing. But the pointers in a structure led me down the C path. If I've inferred incorrectly then the above answer may also be incorrect
 
Old 03-17-2006, 03:43 PM   #4
Pratik H Pandya
LQ Newbie
 
Registered: Jun 2005
Location: India
Distribution: RedHat 9.0,Fedora core 3
Posts: 22

Original Poster
Rep: Reputation: 15
syntactical help

hello will u please give me any example that how i can write a structure into a file specially when it has got pointes to other structures??

Thankx in advance.
 
Old 03-17-2006, 03:52 PM   #5
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
You will need to write the code specific to the structure. Essentially using printf()'s to print out the data and when you come to a pointer dereference the data before printing.

On complex structures you may want to write a function for each sub structure so that you just call the dump function for the sub structure, quite useful if the structure includes an array of pointers to the same sub structure.

You need to be careful if the structure might hold a circular reference.
 
Old 03-17-2006, 04:08 PM   #6
Pratik H Pandya
LQ Newbie
 
Registered: Jun 2005
Location: India
Distribution: RedHat 9.0,Fedora core 3
Posts: 22

Original Poster
Rep: Reputation: 15
ok thank you for your reply. i think it will really help me ill try it and i'll again ask u if i'll find any problem. thank you for such a quick reply.

Thank you very much.
-Pratik H Pandya
 
  


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
Novell is dumping KDE, so I'll be dumping SuSE KimVette SUSE / openSUSE 10 11-12-2005 08:09 PM
Linux file structure go_sooner Linux - Newbie 3 06-05-2005 01:46 AM
f_count of file structure amitgoel25aug Linux User Groups (LUG) 3 08-08-2004 07:39 AM
linux file structure alzogbi Linux - Newbie 5 01-02-2004 03:31 AM
File Structure Stephanie Linux - General 2 07-19-2001 04:59 AM

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

All times are GMT -5. The time now is 01:26 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