Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Quick C++ (Pointer) Question

  • 17-06-2004 02:23PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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