Answers for "how to change pointer passed in from function c"

C
2

how to use a pointer as a parameter in c

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void add(int* a, int* b, int* c)
{
    *c = *a + *b;
}
int main()
{
	int a, b, c;
	a = 3;
	b = 5;
	add(&a, &b, &c);
	printf("%d", c);
}
Posted by: Guest on March-21-2020
0

c programm pointer change in function

void foo(int** p) {     //*p p den allazei , *p **p allazei! deikse null //
      *p = NULL;  /* set pointer to null */
 }
 void foo2(int* p) {
      p = NULL;  /* makes copy of p and copy is set to null*/
 }

 int main() {
     int* k;
     foo2(k);   /* k unchanged */
     foo(&k);   /* NOW k == NULL */
 }
Posted by: Guest on February-19-2021

Code answers related to "how to change pointer passed in from function c"

Code answers related to "C"

Browse Popular Code Answers by Language