Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Quick C++ (Pointer) Question

Options
  • 17-06-2004 3:23pm
    #1
    Registered Users Posts: 1,253 ✭✭✭


    Just a quick question...

    I have a function that takes a char* as a parameter.

    I noticed that if I pass a char array without the '&' it still works...

    Hold on... Example:

    Function Decleration:

    BufferFilter(char *Buffer, int iSize)

    One way to call:

    strExcelFormat[l+1][1] = BufferFilter(Buffer, MAX_ENTRY_SIZE);

    But this seems to work also and I am not sure which is better:

    strExcelFormat[l+1][1] = BufferFilter(&Buffer[0], MAX_ENTRY_SIZE);

    I am thinking that the second way is better as it is just the address of the first element that gets passed, however, I have no idea what is happening with the first one so I have no idea which is better.

    It would be good if they both do the same thing as then I could use the first method which looks better and is easier (for a third party) to understand.

    Any help is appreciated as always! :D

    edit: Hmmm... Think I just found the answer. They are basically the same thing. Am I right???


Comments

  • Closed Accounts Posts: 2,972 ✭✭✭SheroN


    The name of an array is a pointer to its zeroth element.


  • Registered Users Posts: 1,253 ✭✭✭gobby


    Originally posted by SheroN
    The name of an array is a pointer to its zeroth element.
    Beautiful. Cheers man... :cool:


Advertisement