Answers for "ansi c function change address of pointer"

0

ansi c function change address of pointer

void foo(int** p) {
      *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 April-06-2022

Browse Popular Code Answers by Language