c语言中将函数指针作为形参_在C中将指针作为函数参数

c语言中将函数指针作为形参

Pointer as a function parameter is used to hold addresses of arguments passed during function call. This is also known as call by reference. When a function is called by reference any change made to the reference variable will effect the original variable.

指针作为函数参数,用于保存函数调用期间传递的参数的地址。 这也称为按引用调用 。 通过引用调用函数时,对引用变量所做的任何更改都会影响原始变量。

时间示例:使用指针交换两个数字 (Example Time: Swapping two numbers using Pointer)

#include 

void swap(int *a, int *b);

int main()
{
    int m = 10, n = 20;
    printf("m = %d\n", m);
    printf("n = %d\n\n", n);

    swap(&m, &n);    //passing address of m and n to the swap function
    printf("After Swapping:\n\n");
    printf("m = %d\n"

你可能感兴趣的:(指针,java,c++,c语言,python)