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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Quick C++ (Pointer) Question

  • 17-06-2004 2: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