is this a pointer data type?

This is a discussion on is this a pointer data type? within the C Programming forums, part of the General Programming Boards category; Code: int x; . scanf("%d",&x); &x <----- pointer data type? how do I recognize a pointer data type?...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    22

    is this a pointer data type?

    Code:
    int x; 
    .
    scanf("%d",&x);
    &x <----- pointer data type?

    how do I recognize a pointer data type?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >&x <----- pointer data type?
    Yes, because x is an object and the & operator takes the address of that object. Therefore, the result of the expression is a pointer.

    >how do I recognize a pointer data type?
    Implicit or explicit? Explicit is easy, either a variable declared as a pointer or an object whose address is taken. Implicit is harder, this mostly concerns the use of arrays where the array is converted to a pointer to the first element.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    22
    thx for your help. How about this example? which of this three is a pointer data type ?

    Code:
    int cars[5][4][3};
    
    auto=cars[3][2][1];
    
    auto=cars[3][2][1];
    
    auto=cars[3][2][1];

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    I can guarantee that auto is not the correct type for all of those assignments. But the first two are pointers and the second is an int.
    My best code is written with the delete key.

  5. #5
    Registered User
    Join Date
    Aug 2004
    Posts
    22
    Im so confuse

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,533
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you check what is wrong with this code
    By Ron in forum C++ Programming
    Replies: 4
    Last Post: 08-01-2008, 10:59 PM
  2. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 06:33 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  5. All u wanted to know about data types&more
    By SAMSAM in forum Windows Programming
    Replies: 6
    Last Post: 03-11-2003, 02:22 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21