Passing string to a function in C - with or without pointers?

前端 未结 3 1119
借酒劲吻你
借酒劲吻你 2020-12-13 05:11

When I\'m passing a string to the function sometimes I use

char *functionname(char *string name[256])

and sometimes I use it without pointe

3条回答
  •  盖世英雄少女心
    2020-12-13 05:29

    An array is a pointer. It points to the start of a sequence of "objects".

    If we do this: ìnt arr[10];, then arr is a pointer to a memory location, from which ten integers follow. They are uninitialised, but the memory is allocated. It is exactly the same as doing int *arr = new int[10];.

提交回复
热议问题