Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > how to get structure elements?

Reply
Thread Tools

how to get structure elements?

 
 
k3rb
Guest
Posts: n/a
 
      05-03-2005
hi everyone sorry for the stupid question but I can't figure it out how
I can get elements of a structure?
example I want to get all the elements in the structure which I don't
know?
I am trying to find out where are inode_t, FILE and DIR structures but
I can find them?
thanks for your help in advanced

 
Reply With Quote
 
 
 
 
Bharath
Guest
Posts: n/a
 
      05-03-2005
Didn't get your question! Are you asking about the data types inode_t?
Have you checked in the relevant header (.h) files?

 
Reply With Quote
 
 
 
 
Martin Ambuhl
Guest
Posts: n/a
 
      05-03-2005
k3rb wrote:
> hi everyone sorry for the stupid question but I can't figure it out how
> I can get elements of a structure?
> example I want to get all the elements in the structure which I don't
> know?
> I am trying to find out where are inode_t, FILE and DIR structures but
> I can find them?
> thanks for your help in advanced
>

inode_t and DIR structures are not standard C. The pointer to FILE is,
but the type is intended to be opaque. There is nothing in a FILE
struct that can be assumed to be portable; it is completely
implementation-specific. If you want to play the dangerous game of
looking inside those black boxes, you may want to look to
system-specific headers. On the implementation I use most often, the
struct FILE is defined in <stdio.h>, but this is not guaranteed. On the
other hand, the non-standard struct DIR is *not* defined in the
non-standard header <dirent.h>; what is there is a typedef to a library
internal struct. The source for that internal struct is available, but
that need not be true. If you *really* need this kind of information --
think carefully before saying 'yes' -- ask in a newsgroup for your
implementation.
 
Reply With Quote
 
SM Ryan
Guest
Posts: n/a
 
      05-03-2005
"k3rb" <> wrote:
# hi everyone sorry for the stupid question but I can't figure it out how
# I can get elements of a structure?

You can't do it within the language: C doesn't support that kind of introspection.

# example I want to get all the elements in the structure which I don't
# know?
# I am trying to find out where are inode_t, FILE and DIR structures but
# I can find them?
# thanks for your help in advanced

Depends on the implementation and operating system.
You might be able to do something like

echo '#include <stdio.h>' > /tmp/x.c
cc -E /tmp/x.c >x.i
grep -B 100 '} FILE' x.i

--
SM Ryan http://www.rawbw.com/~wyrmwif/
I love the smell of commerce in the morning.
 
Reply With Quote
 
k3rb
Guest
Posts: n/a
 
      05-04-2005
thanks SM Ryan that is exactly what I need.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Iterate through a list of structure arrays of structure to get outthe field stuie_norris@yahoo.com.au C Programming 2 12-12-2012 09:18 PM
Memory allocation in Structure to Structure pra_ramli@rediffmail.com C++ 2 03-09-2006 05:51 AM
Copy String structure "A" to string structure "B" Leo Nunez C Programming 3 02-09-2005 05:14 AM
Pointers to structure and array of structure. Excluded_Middle C Programming 4 10-26-2004 05:39 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57