Re: C question!



"Robby" <Robby@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:513D47C1-CE7C-4F67-918B-7307C0E87A71@xxxxxxxxxxxxx
If I have a variable (lest call it "x") containing a number between 1
and 10 where this variable is to contain the numerical value
corresponding
to a member of a structure, how can I access the member? For sample
purposes, right now I am using a structure.

For example:
============================================

struct msgs{
int MSG1;
int MSG2;
int MSG3;
int MSG4;
int MSG5;
int MSG6;
int MSG7;
int MSG8;
int MSG9;
int MSG10;
} *obj_msgs_x;

Why not just have an array of 10 integers?
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Re: problem with cast and unions
    ... The part where there is that problem is about conversion from a C float ... to a Small "cell" (actually an int). ... structure, and even then, only if it was NOT the member most recently ... need to declare the union. ...
    (comp.lang.c)
  • Re: Read-only, as opposed to const member
    ... >> Don't change it from int to double. ... Every Cheese object needs to have a member function which returns ... No more, no less, just a read-only member variable. ...
    (comp.lang.cpp)
  • Re: C++ in ternms of C
    ... >A class has its member variables, ... > int b, c, d; ... >the compiler performs these checks to tell us that our code conforms to the ... >design specification of the class (for example, not changing the member ...
    (microsoft.public.vc.language)
  • C question!
    ... to a member of a structure, how can I access the member? ... int MSG1; ... Now I know that to store 50 in the member called "MSG4" I can do: ... Instead of a structure, I know I can use a simple array, or do an array ...
    (microsoft.public.vc.language)
  • [PATCH 1/2] Extend sys_clone and sys_unshare system calls API
    ... better names for new flag and data types. ... but the pointer to the struct long_clone_struct which currently ... that the desired member is provided from ... int sched_priority; ...
    (Linux-Kernel)

Loading