Create a C function that accepts parameters of different data types

前端 未结 6 1270
陌清茗
陌清茗 2021-02-09 02:07

I\'m relatively new to the C programming language, and I\'m trying to figure out how to create a function that can accept different types of data as parameters. The function is

6条回答
  •  情深已故
    2021-02-09 03:07

    The answer is quite simple. You do need a function for this task. Just try this piece of code

    #define len(array) sizeof(array)/sizeof(*array)
    

    and that's it.

    Important note: As pointed out in the comments, this will not work for dynamically allocated arrays.

提交回复
热议问题