0

What is the difference between on those two formate in C function?

#include <stdio.h>
void basic_math(double* m_a, double* m_b, double* m_c) 
{ 
   *m_c = *m_a + *m_b;
}
int main () {
  double a = 2.5;
  double b = 3.2;
  double c;
  basic_math(&a, &b, &c); 

printf("ans is %.2lf\n", c); 
return 0;
 
}

if

void basic_math(double* m_a, double* m_b, double* m_c) 
{ 
   *m_c = *m_a + *m_b;
}

change into

void basic_math(double *m_a, double *m_b, double *m_c) 
{ 
   *m_c = *m_a + *m_b;
}

any difference on that?

fungfranco
  • 39
  • 1
  • 4
  • @Lundin just edit the title – fungfranco Feb 04 '22 at 12:47
  • `void basic_math(double* m_a, double* m_b, double* m_c)` and `void basic_math(double *m_a, double *m_b, double *m_c)` are the same. – JASLP doesn't support the IES Feb 04 '22 at 12:48
  • [Also relevant.](https://stackoverflow.com/questions/34758270/why-is-the-asterisk-in-a-pointer-declaration-specific-to-the-identifier-and-not) – Eric Postpischil Feb 04 '22 at 12:49
  • 13 answers [here](https://stackoverflow.com/questions/180401/placement-of-the-asterisk-in-pointer-declarations). Also answered [here](https://stackoverflow.com/questions/30400926/difference-between-and-pointers-in-c/30401234#30401234) – mmixLinus Feb 04 '22 at 12:49

0 Answers0