How to use a pointer as a parameter in C

1 Answer

0 votes
#include <stdio.h>

void add(int *a, int *b, int *result) {
    *result = *a + *b;
}

int main()
{
	int a, b, result;
	
	a = 34;
	b = 12;
	add(&a, &b, &result);
	
	printf("%d", result);

    return 0;
}



   
/*
run:
    
46
    
*/

 



answered Nov 27, 2021 by avibootz

Related questions

1 answer 225 views
5 answers 459 views
1 answer 186 views
186 views asked Feb 1, 2020 by avibootz
2 answers 163 views
1 answer 166 views
...