A call to a structure. 
Author Message
 A call to a structure.

Hi,

I have a structure with some variables. For example called
var1,var2,var3.

struct str
{

        int var1;
        char var2;
        long var3;

Quote:
};

I would like to access this structure from the commandline, when I am
running the program.

Something like: prog var1

The program has to parse and convert the text into a call of the
variable in the structure. Is that possible or do I have to make a table
that maps all the variablenames?

Help will be very much appreciated.

Thanks

Chris.

--== Sent via Deja.com http://www.*-*-*.com/
---Share what you know. Learn what you don't.---
--



Sun, 11 Nov 2001 03:00:00 GMT  
 A call to a structure.

Quote:

>Hi,
....
>I would like to access this structure from the commandline, when I am
>running the program.

>Something like: prog var1

>The program has to parse and convert the text into a call of the
>variable in the structure. Is that possible or do I have to make a table
>that maps all the variablenames?

You'll have to parse it out. By the time you have an executable the compiler
has removed symbols like variable names from normal view.  The may still
exist in a debugging symbol table, but you can't use them directly.  The
only reason for having symbolic variable names is for the programmer's
convenience.
--



Mon, 12 Nov 2001 03:00:00 GMT  
 A call to a structure.
: Hi,

: I have a structure with some variables. For example called
: var1,var2,var3.

: struct str
: {

:       int var1;
:       char var2;
:       long var3;
: };

: I would like to access this structure from the commandline, when I am
: running the program.

: Something like: prog var1

: The program has to parse and convert the text into a call of the
: variable in the structure. Is that possible or do I have to make a table
: that maps all the variablenames?

Since the variable names pretty much disappear after compilation
(except for the debugging info), you will have to map the string
representation of the variable names to the variable itself. I have a
ternary search tree package I wrote available on my website. It was
written specifically for associating a string key with a pointer to
some data object. It may help solve your problem.

http://www.octavian.org

Peter Friend

---
Software Engineer
EarthLink Network
--



Mon, 12 Nov 2001 03:00:00 GMT  
 A call to a structure.

Quote:

> The program has to parse and convert the text into a call of the
> variable in the structure. Is that possible or do I have to make a table
> that maps all the variablenames?

You have to make a table.  If you have several instances of the
structure, the offsetof macro in <stddef.h> may be useful.

On the other hand, since the members of your structure all had
different types, a switch statement or a chain of ifs (if you're
comparing strings) might be the simplest solution.
--



Mon, 12 Nov 2001 03:00:00 GMT  
 A call to a structure.


[...]

Quote:
> The program has to parse and convert the text into a call of the
> variable in the structure. Is that possible or do I have to make a table
> that maps all the variablenames?

You have to make a table. Once a program's compiled, it has no concept of
such a thing as a `name' (of anything) (except in really special
circumstances). The compiled code will just contain the offsets into the
structure.

--
+- David Given ---------------McQ-+


+- http://wired.st-and.ac.uk/~dg -+
--



Mon, 12 Nov 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Interrupted read() calls update stat structure (Unix-specific)

2. need helping calling values from structure

3. Help : Cross reference/Call structure of C function calls

4. hierarchical class structure vs. calling another class

5. Mixed Language - VBA calling C DLL passing a structure

6. Using structures and createthread function calls

7. structure chart/calling tree

8. Looking for call structure generator

9. Saving structures to a file (also called Help!)

10. Call graph and data structure visualization from source

11. Need help in declaring a C# structure from C structure

12. Structure to Structure

 

 
Powered by phpBB® Forum Software