Thread: byte array plus integer literal question

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    2

    byte array plus integer literal question

    I am trying to understand what adding the literal integer values of 256 and 512 does to the byte array as described in the C code sample below which is a snippet from the Microsoft Permutative Encoding Algorithm for PST files. I am porting this to another language and want to understand what happens to the array when you add a literal to it, is it adding that value to all the elements in the array or is it causing a bit shift of some sort?

    Code:
    byte mpbbCrypt[] = { 65,  54,  19, ... }; // A byte array initialized with 256 values
    
    #define mpbbR   (mpbbCrypt)
    #define mpbbS   (mpbbCrypt + 256)
    #define mpbbI    (mpbbCrypt + 512)
    Thanks,
    PC

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Googlified: Pointer Arithmetic

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    2
    Thanks, my mistake was assuming the crypt array only consisted of 256 elements when in fact there are 768 and the defined variables are just pointers into that array offset every 256 elements. My solution will be break the array into three separate smaller arrays of 256 to start with.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ integer array question .. plz help
    By amerjamil in forum C++ Programming
    Replies: 6
    Last Post: 12-21-2010, 01:43 AM
  2. question about string literal
    By pangzhang in forum C Programming
    Replies: 6
    Last Post: 07-31-2010, 07:25 AM
  3. Byte Array / Integer conversion
    By AdLab in forum C Programming
    Replies: 2
    Last Post: 05-07-2008, 08:04 AM
  4. Appended integer literal to std::string
    By Tonto in forum C++ Programming
    Replies: 7
    Last Post: 07-30-2005, 11:49 AM
  5. 5 Byte Integer
    By NewPappa in forum C Programming
    Replies: 11
    Last Post: 07-22-2004, 11:57 PM