Thread: Variable passing

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    27

    Variable passing

    When passing the variable bytes to the loadBytes function, it somehow get the value zero when treated in the stackwrite function. If I set the value bVar to any constant value it's ok.

    Code:
    byte bytes[64];
    bytes[0] = 0xef;
    bytes[1] = 0xcd;
    
    void loadBytes(int addr, int n, byte *bytes) {
    uint16 bVar;
    bVar = (uint16)bytes[0]|((uint16)bytes[1]<<8);
    
     for (j=0; j<1; j++)
        {
          StackWrite(sibleyStack,0, bVar);
        }
    
    }
    
    lodBytes(0, 0, bytes);
    Please help me out here.

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    27
    sorry about the misspelled loadBytes in the end (that's not the error though, hehehe)!!

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    the last parameter to loadBytes is a pointer, you are passing a single integer (assuming uint16 is typedefed as unsigned int). Didn't your compiler produce an error about that?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Make a variable available everywhere without passing?
    By Austin in forum C++ Programming
    Replies: 9
    Last Post: 03-03-2005, 11:38 AM
  2. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  3. variable passing problem
    By bsimbeck in forum C Programming
    Replies: 3
    Last Post: 02-09-2003, 06:43 PM
  4. About classes and HINSTANCE variable to Main
    By conright in forum Windows Programming
    Replies: 2
    Last Post: 01-01-2003, 08:00 PM
  5. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM