![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A program to trace execution of another program | jiten_hegde | High Level Programming | 3 | 1 Week Ago 02:26 AM |
| How to access the C program variables in shell script | bhakti | Shell Programming and Scripting | 3 | 07-12-2006 10:41 PM |
| Passing shell variables to awk program.. | Vishnu | Shell Programming and Scripting | 1 | 07-17-2004 07:04 AM |
| Dummie: How do I get variables mid program | RichardB | UNIX for Dummies Questions & Answers | 1 | 05-06-2002 11:07 AM |
| help, what is the difference between core dump and panic dump? | aileen | UNIX for Dummies Questions & Answers | 1 | 06-11-2001 05:08 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi,
Wish if could provide some clues. How do I dump all the C program variables(global) into say a file with their names and the values. So that when I restart the application again I could use this same file for reinitializing.Is this possible? Thanks, Reji |
| Forum Sponsor | ||
|
|
|
|||
|
To do this the way you state it is only possible if you use the symbol table, and you do not want to use a debugging tool as part of your program :-)
You should put all your globals into a struct, and then read and write that struct. lets say you have a name, and some int, and a float: int GL_i; char GL_name[256]; float GL_f; Change this to: struct { int i; char name[256]; float f; } GL; As a rule, if you have lots of globals spread out like in the first example, your program is badly structured. A global is a potential bug. For every global, contemplate making it static. For the structure above, contemplate storing it in a dynamically allocated buffer - you will win big: You can have multiple instances, and your program (or library) will become safer, for a library this may provide reentrancy (each instance has its own data - or you will have to lock it!) Atle
__________________
PS All of the above is to be read as '... unless I am wrong' ENDPS |
|||
| Google UNIX.COM |