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?
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:
Change this to:
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!)
Hi there,
I need urgent help with a small program that is run via shell script. Unfortunately I only understand the bare basics of shell scripting and can't figure out how to do this.
We have a program that tests the connection between 3 servers. I have a script that lets the program run on... (15 Replies)
So I need some help with this. Pardon me if I'm posting in the wrong forum, after some googling for my answer and finding nothing I found this forum. It seemed appropriate for what I was seeking. I just didnt find a forum that concerned the use of GDB. I'm learning to use the C language and GDB.... (2 Replies)
this method is not working.I am having a problem to use variables in system command. i cannot use the variables in system command.
this how i was did
system("whereis command");
this method works very fine. but, i want use the commands as variable.
that means i want only pass the variables.... (6 Replies)
Hello Geniuses of the unix world. please help, stupid chemist. I have the following script that I need to create a file. Doesnt make sense unless i explain this way: I need to create a file called summary.in I would like all these lines to be inserted however in the command line I would like the... (1 Reply)
hi
I wanted to access the C program variables in shell script.
This script is called from the same C program.
What are the ways in which i can access variables
thankx (3 Replies)
I'm writing a simple program in unix and was wondering how mid switch I can run a program and get someone to enter variables for it i.e.:
#!/bin/csh -f
echo "If you wish to do v press v"
echo "If you wish to compile press c"
echo "If you wish to add an entry press a"
echo "If you wish to... (1 Reply)