request for member ‘idxPonteiro’ in something not a structure or union

This is a discussion on request for member ‘idxPonteiro’ in something not a structure or union within the C Programming forums, part of the General Programming Boards category; util.h Code: typedef struct Pesos { u32_t idxPonteiro; u32_t Pesos[100]; u16_t iVazio; } strPesos; u8_t chksum8(u8_t *buff, u32_t tam); u8_t ...

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    158

    request for member ‘idxPonteiro’ in something not a structure or union

    util.h

    Code:
    typedef struct Pesos {
    	u32_t	idxPonteiro;
        u32_t	Pesos[100];
    	u16_t	iVazio;
    } strPesos;
    
    u8_t chksum8(u8_t *buff, u32_t tam);
    u8_t hex2bin(u8_t dig);
    
    void CriarPilha(strPesos * strPilha);
    void InserePilha(strPesos strPilha, u32_t peso);
    u32_t PegarPilha(strPesos strPilha);
    u16_t PilhaVazia(strPesos strPilha);
    void ZerarPilha(strPesos strPilha);
    util.c
    Code:
    void CriarPilha(strPesos * strPilha)
    {
    	//strPesos PesosHBM;
    	strPilha.idxPonteiro = 0;
    	strPilha.iVazio = 1;
    }
    app.c
    Code:
    strPesos PesosHBM;
    
                    CriarPilha(PesosHBM);
                	InserePilha(PesosHBM, 40);
                	InserePilha(PesosHBM, 50);
                	InserePilha(PesosHBM, 60);
    
                	sprintf(strTestePilha, "%d", PegarPilha(PesosHBM));
                	display_setcurpos(1,10);
                	display_print(strTestePilha);
    Error:

    util.c: In function ‘CriarPilha’:
    util.c:49: error: request for member ‘idxPonteiro’ in something not a structure or union

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    The error message means what it says: you are requesting (via using the dot notation .idxPonteiro) a member in something that isn't a structure or a union. And the error message is right: strPilha is a pointer; it is not a structure or a union. C has a shortcut notation that says "the thing on the left isn't a structure, but it points to one, so use the structure pointed to", and that notation is:
    Code:
    strPilha->idxPonteiro

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    158
    great, thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 11-10-2010, 04:04 PM
  2. Replies: 4
    Last Post: 09-04-2010, 09:12 AM
  3. Replies: 1
    Last Post: 05-18-2010, 04:14 AM
  4. Problem Passing Structure Reference To Function
    By soj0mq3 in forum C Programming
    Replies: 9
    Last Post: 04-24-2010, 10:27 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

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