Thread: Copy operation error I do not understand

  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733

    Question Copy operation error I do not understand

    This is the error I was given
    Code:
    error: array subscript is not an integer
         *end = num->buff[pos];
    end & num->buff are both pointers to an unsigned char, num->buff obviously is an array of unsigned char but nevertheless is still a pointer to an unsigned char, I was under the impression that the above code would copy the value of num->buff[pos] into the unsigned char pointed to by *end, can anybody enlighten me as to what the possible problem is?

    Incedently this is a hobby project so there should be no moral/ethical issues here.

  2. #2
    Guest
    Guest
    What is the type of pos? Maybe the issue lies there.

  3. #3
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,111
    Please post the code if possible in code tags so we can see it in context.

  4. #4
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    Here's a copy paste of relevant areas of code.
    Code:
    #define ZIC signed char
    #define ZUC unsigned char
    #define ZIS signed short
    #define ZUS unsigned short
    #define ZI signed int
    #define ZU unsigned int
    #define ZIL signed long
    #define ZUL unsigned long
    
    typedef bool zb_t;
    typedef ZIC zic_t;
    typedef ZUC zuc_t;
    typedef ZIS zis_t;
    typedef ZUS zus_t;
    typedef ZI zi_t;
    typedef ZU zu_t;
    typedef ZIL zil_t;
    typedef ZUL zul_t;
    // ...
    typedef struct ZUV {
        zus_t size;
        zul_t bits;
        char const *endian;
        zuc_t *buff;
    } zuv_t;
    // ...
    void _zuvMax( zuv_t *num, zuc_t *max, zuc_t *end, zus_t *pos ) {
        zul_t bits = num->bits % CHAR_BIT;
        *pos = num->size - 1;
        *end = num->buff[pos];
        *max = ~(UCHAR_MAX << bits);
    }

  5. #5
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    never mind just realised my error, forgot to dereference pos

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. primary expression error when calling operation
    By elsparko in forum C++ Programming
    Replies: 2
    Last Post: 05-18-2010, 12:43 PM
  2. Can't understand my error...
    By dnguyen1022 in forum C++ Programming
    Replies: 22
    Last Post: 03-27-2009, 09:33 AM
  3. Can't understand this error
    By csonx_p in forum C++ Programming
    Replies: 6
    Last Post: 08-25-2008, 10:11 AM
  4. illegal operation error
    By xlordt in forum C Programming
    Replies: 2
    Last Post: 09-01-2003, 07:53 AM
  5. Explain copy operation...
    By Gamma in forum C++ Programming
    Replies: 3
    Last Post: 04-14-2002, 08:11 PM

Tags for this Thread