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 228 views
5 answers 470 views
1 answer 189 views
189 views asked Feb 1, 2020 by avibootz
2 answers 167 views
1 answer 170 views
...