0

I am little confused about how pointers are/or can be used. for example:

int addtwonumbersfunction(int* number_1, int* number_2)

Is it same as: int addtwonumbersfunction(int *number_1, int *number_2)?

Does it matter where * is placed? after int, or before variable?

Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
just peter
  • 115
  • 2
  • 9

2 Answers2

2

Does it matter where * is placed? after int, or before variable?

No it does not matter. Your two examples are semantically the same.

Bill Lynch
  • 80,138
  • 16
  • 128
  • 173
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
1

It doesn't matter, you can write both. int is the main type, so on multiple variable declaration, you'd have to add * everytime. Some prefer int* var because of grouping type & variable name, others like int *var because of the behaviour i described with multiple declaration.

Youka
  • 2,646
  • 21
  • 33