Re: is it possible to access members of struct in loop?



Erich Pul wrote:
hi!

is it possible to access the members of a struct (e.g. 10 members) in a
loop, comparable to an array?

No (unless those 10 members happen to be an array!), C has nothing like
the foraech construct found in some other languages.

--
Ian Collins.
.



Relevant Pages

  • Re: #defining an array within another in C language
    ... you do not know the number of elements of the array. ...     int var; ... C99 flexible array members or the plain old "struct hack". ...
    (comp.lang.c)
  • Re: C, strcat
    ... Actually a 1-length array of char. ... >members (all char strings) contained in a structure. ... struct member_data ...
    (alt.comp.lang.learn.c-cpp)
  • Re: structure toupperlower?
    ... >> I need to properly format the case of a struct. ... Are you trying to iterate over the members of a struct? ... you probably can if you first build an array each element ... The toupperand tolowerfunctions apply to a single character: ...
    (comp.lang.c)
  • Re: void* passed as funtion parameters?
    ... You could use a union type to store the array and store the array ... You could also attach the type to the struct itself, ... having members with the same name, you could use a macro in place of a ...
    (microsoft.public.vc.language)
  • Re: Getting value from an array using another array
    ... If you show how you are accessing the members of p, ... You realise that is permanently modifying the array passed to the ... You can get rid of the not logic by re-arranging the loop: ... A little more robust, but not much. ...
    (comp.lang.javascript)