Thread: pointer question: * space name

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    23

    pointer question: * space name

    FILE *open

    and

    FILE * open

    are same thing. Space between * open makes any different?

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    same thing, no difference.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    FILE* open
    FILE * open
    FILE *open
    All the same thing.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    If you do this
    int* ptr, var;
    you might be tempted into thinking that var was a ptr to an int (it isn't).

    int *ptr, var;
    Would make it clearer that the 'pointer' belonged to the ptr variable only, and not to var.

    On the other hand, it's worth noting that mixing declarations like this is poor style to begin with. The amount of effort it saves is much less than the confusion it can cause.
    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.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I like to think that int* a pointer to an int, but I also know that int* ptr, var, only ptr is int* and var is int, and thus I never declare more than one pointer per line.
    Go, go, C/C++ semantics!
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. double astrix pointer question..
    By transgalactic2 in forum C Programming
    Replies: 104
    Last Post: 01-19-2009, 05:02 AM
  2. a pointer to a function question..
    By transgalactic2 in forum C Programming
    Replies: 17
    Last Post: 10-21-2008, 11:47 AM
  3. A pointer question.
    By joenching in forum C++ Programming
    Replies: 7
    Last Post: 03-20-2008, 04:10 PM
  4. Pointer alloc size question
    By mikahell in forum C++ Programming
    Replies: 3
    Last Post: 09-06-2006, 07:55 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM