address of struct variable?

This is a discussion on address of struct variable? within the C Programming forums, part of the General Programming Boards category; Hi, I was wondering if anyone could tell me how to pass the address of a specific variable in a ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    58

    Smile address of struct variable?

    Hi, I was wondering if anyone could tell me how to pass the address of a specific variable in a struct?

    Example:

    Code:
    typedef struct
    {
      uint8_t     A;
      uint8_t     B;
      ExtAddr_t   C;
    } stuff_t;
    
    doSomething(&stuff_t.A);
    Doing the above I get the warning: “passing argument 1 of 'doSomething‘ from incompatible pointer type”

    Any pointers would be greatly appreciated

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,725
    More like:
    Code:
    stuff_t stuff;
    doSomething(&stuff.A);
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,604
    The first does not compile since you can't take something from a blueprint.
    Anyway, if you'd follow laserlight's advice and make doSomething take a uint8_t* pointer, then it should work fine.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting from C to C++
    By Taka in forum C++ Programming
    Replies: 5
    Last Post: 04-08-2009, 02:16 AM
  2. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  3. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 06:17 PM
  4. Replies: 16
    Last Post: 10-29-2006, 04:04 AM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21