How can I return more than one value through function in C?

前端 未结 5 932
迷失自我
迷失自我 2020-12-19 06:56

I have been asked in an interview how one can return more than one value from function. I have answered saying by using pointers we can achieve(call by reference) this in C.

5条回答
  •  悲&欢浪女
    2020-12-19 07:08

    There are a few ways:

    1. Return value using the return statement (as you already know)
    2. Return via references.
    3. Return values via the heap.
    4. Return values via global variables.

提交回复
热议问题