pointer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajunboys
    New Member
    • Jul 2013
    • 2

    pointer

    known char *cts = "hello, girl!". so what is the *cts, cts? Why?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Look at this in C:

    Code:
    int x;
    this says that the variable x is an int.
    Then try:

    Code:
    int x,y;
    This says the variable x and y are ints.
    OK so far. Now try:

    Code:
    int x,y,*z;
    This says that the variables x,y and *z are ints.
    OK. Now put these definitions on separate lines:

    Code:
    int x;
    int y;
    int *z;
    Finally, since whitespace doesn't count, you can move the *:

    Code:
    int x;
    int y;
    int* z;
    Nothing has changed. x is an int. y is an int. and *z is an int.

    With respect to *z, the variable z is called a pointer. A pointer is to contain an address. In this case z must contain the address of an int.

    If you display z you see the address of the int. If you display *z you see the int.

    Comment

    • nnk1220
      New Member
      • Sep 2013
      • 3

      #3
      cts is a just pointer to string.

      similar to any other pointer

      Comment

      Working...