0

I have seen programs that use both char* name; and char *name for pointers and do not understand the difference.

I thought all pointers required a * before the variable name so why do some variable types have them used at the end instead?

char* name[]; vs char *name[];

This confuses me as a beginner so thank you for understanding my simple question.

takendarkk
  • 3,347
  • 8
  • 25
  • 37
Mayron
  • 2,146
  • 4
  • 25
  • 51

2 Answers2

2

They're equivalent. Whitespace has no meaning, apart from separating tokens that need separating. These tokens don't need separation, so you can put as much or as little space between them as you deem aesthetically pleasing.

Mike Seymour
  • 249,747
  • 28
  • 448
  • 644
1

char * and char* are both same and serve same purpose while declaring variables. It's just a matter of preference where you want to put the pointer sign.

ravi
  • 10,994
  • 1
  • 18
  • 36
  • Thank you so much, the lecturer never explained this but happy to know it doesn't mean anything special :) – Mayron Nov 12 '14 at 12:19