Thread: invalid type argument of `->'

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    161

    invalid type argument of `->'

    Hello guys

    This is a packet that I have to send to another application..

    Code:
    #define M_PKT_SIZE 1400  // max dimension of a packet
    
    // a packet has a size and a data
    typedef struct aPacket {
    	int pkt_length;
    	char data[M_PKT_SIZE]; 
    } Packet;
    This is supposed to be a buffer of packets, an array of packets:

    Code:
    // array of packets, it is the window
    Packet window[MAX_WINDOW_SIZE];
    Here I've received a packet form the local application and before sending it through the wire, I put it in the packet buffer (window)..

    Code:
    int r_send(const char * pkt, int pktlen) {
    ...
    window[nextSequenceNumber % BUFFER_LENGTH]->pkt_length = buflen;
    strcpy(window[nextSequenceNumber % BUFFER_LENGTH]->data, buf);[/
    ...
    ERROR: invalid type argument of `->'

    Then the same..when I have the packet in the buffer and i want to send it..
    Code:
    u_send (window[i % MAX_WINDOW_SIZE]->data,
    window[i % MAX_WINDOW_SIZE]->pkt_length);
    ERROR: invalid type argument of `->'

    How can I fix this? Do I have to allocate memory before to store the packet in the packet buffer (window)? Isn't the memory allocated before because it is in an array?

    Thanx
    This forum is the best one I've ever seen. Great ppl, great coders

  2. #2
    Registered User
    Join Date
    Mar 2005
    Posts
    135
    Instead of using '->' use: '.' (the dot operator)

    example: window[nextSequenceNumber % BUFFER_LENGTH].data

    '->' is used only on structures declared as pointers

    and

    '.' for normal structures such as the one you created.

    ------------------------------------------------------------------

    Packet window[10] // use '.'

    Packet *window[10] // use '->'

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    161
    ahhhhhh got it!
    I'll try thanx

    see u later for the next bug
    This forum is the best one I've ever seen. Great ppl, great coders

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fseek failing - Error: Invalid argument
    By avi2886 in forum C Programming
    Replies: 14
    Last Post: 05-14-2009, 08:49 PM
  2. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  3. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 04:33 PM
  4. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  5. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM