Pointer array in C#

Discussion in 'Meetups & Events' started by siegelracing, Jan 15, 2009.

  1. siegelracing

    siegelracing Registered Vendor<br><b><font color="#666666">bion

    Joined:
    Aug 19, 2004
    Messages:
    1,553
    Likes Received:
    0
    We're having a programming problem. Anybody know how you can have a pointer to an array that has a pointer in it?

    Siegel
     
  2. Kokopelli

    Kokopelli Active Member

    Joined:
    Oct 11, 2003
    Messages:
    2,327
    Likes Received:
    0
    Your a tuner not a developer.

    I suggest you step away from the computer :rofl:
     
  3. nsvwrx

    nsvwrx Active Member

    Joined:
    Oct 8, 2005
    Messages:
    2,726
    Likes Received:
    0
    i am a c# developer for a living, what do you need?
     
  4. nsvwrx

    nsvwrx Active Member

    Joined:
    Oct 8, 2005
    Messages:
    2,726
    Likes Received:
    0
    FYI using unsafe code FTL.
     
  5. siegelracing

    siegelracing Registered Vendor<br><b><font color="#666666">bion

    Joined:
    Aug 19, 2004
    Messages:
    1,553
    Likes Received:
    0
    We need to know how you can have a pointer to an array that has a pointer in it?
     
  6. siegelracing

    siegelracing Registered Vendor<br><b><font color="#666666">bion

    Joined:
    Aug 19, 2004
    Messages:
    1,553
    Likes Received:
    0
    This is it in C+:

    SBYTE_ARRAY InputMsg;
    SBYTE_ARRAY OutputMsg;
    unsigned long status;

    unsigned char EcuAddr[1]; // ECU target address array
    unsigned char KeyWord[2]; // Keyword identifier array

    EcuAddr[0] = 0x33; // Initialization address used to activate all ECUs

    InputMsg.NumOfBytes = 1; // ECU target address array contains one address.
    InputMsg.BytePtr = &EcuAddr[0]; // Assign pointer to ECU target address array.
    OutputMsg.NumOfBytes = 2; // KeyWord array has 2 bytes allocated.
    OutputMsg.BytePtr = &KeyWord[0]; // Assign pointer to KeyWord array.

    status = PassThruIoctl(ChannelID, FIVE_BAUD_INIT, &InputMsg, &OutputMsg);
     
  7. nsvwrx

    nsvwrx Active Member

    Joined:
    Oct 8, 2005
    Messages:
    2,726
    Likes Received:
    0
    Ah c++, sorry havent done that in years..
     
  8. EFI-Unlimited

    EFI-Unlimited New Member

    Joined:
    Jan 15, 2009
    Messages:
    1
    Likes Received:
    0
    Well, we need that code translated into C#

    specifically, the line

    OutputMsg.BytePtr = &KeyWord[0]; // Assign pointer to KeyWord array.

    I think I have the rest of it figured out except for, I don't want the memory manager messing with the variables before I pass the pointers to the following function call, so I think a fixed statement needs to work its way in somewhere, but it is unclear how to have a fixed statement cover a block of code.

    Brian
     
    #8 EFI-Unlimited, Jan 16, 2009
    Last edited: Jan 16, 2009
  9. nsvwrx

    nsvwrx Active Member

    Joined:
    Oct 8, 2005
    Messages:
    2,726
    Likes Received:
    0
    HMM you dont want the GC messing with the vars right?

    You could put that in a Unsafe block and tell the GC not the manage those vars..
     
  10. nsvwrx

    nsvwrx Active Member

    Joined:
    Oct 8, 2005
    Messages:
    2,726
    Likes Received:
    0
  11. Cool_____

    Cool_____ Banned

    Joined:
    Sep 5, 2005
    Messages:
    7,338
    Likes Received:
    0
    What software are you using Scott? IbOpenSource

    You can have pointers pointing to pointers that point to other pointers....yeah messy especially when the GC starts doing things.

    Too bad it's not in Java....I'd crack it in a heartbeat.
     
  12. XanRules

    XanRules Active Member

    Joined:
    Jun 4, 2007
    Messages:
    1,496
    Likes Received:
    0

    [​IMG]
    I had to.
     

Share This Page