-7

Does below code segments mean the same thing or each one has a different meaning

char *data = "blah";
char* data = "blah";
char * data = "blah";
Alex David
  • 585
  • 1
  • 11
  • 32

3 Answers3

0

The three are same. The only differences are,

  • The position of the asterisk and the whitespace around them(which is done according to one's preference)
  • The string literals "blah" could be stored in the same memory location or different locations. From the C11 standard,

    6.4.5 String literals

    [...]

    1. It is unspecified whether these arrays are distinct provided their elements have the appropriate values. If the program attempts to modify such an array, the behavior is undefined.
Spikatrix
  • 20,225
  • 7
  • 37
  • 83
0

All of them are same

char *data = "blah";
char* data = "blah";
char * data = "blah";
char*data = "blah";
Gopi
  • 19,784
  • 4
  • 24
  • 36
0

All of them are same. They all mean, data is a pointer to type char. The space in between don't make any difference. IMHO, you should have googled/binged that up.

EDIT:: Copied from The Paramagnetic Croissant comment, I think it will help others:: cdecl.org

Abhineet
  • 5,320
  • 1
  • 25
  • 43