Article View: comp.os.ms-windows.programmer.tools.mfc
Article #11Re: Newbie pointer question
From: Tanmoy Bhattacharya
Date: Sun, 10 Sep 1995 18:59
Date: Sun, 10 Sep 1995 18:59
40 lines
2433 bytes
2433 bytes
In article <9a7cb$d1625.8d@news.tcsmgmt.com>, vashist@tcsmgmt.com (Vashist Worah) writes: |> This may seem trivial to veterans here, but I am trying to figure out |> what in the world is the difference in declaring pointers in the two |> different manners illustrated below (VC++ 2.2): |> |> 1) double* x |> 2) double *x None. C is defined in terms of `tokens'. Whitespace forms part of some token (e.g. string literal or character tokens containing blanks), but its major use is to separate tokens from each other (see note below). Each of the above two forms give rise to the same sequence of three tokens: `double',`*' and `x'. The same set of tokens result from `double*x' with no whitespace whatsoever. double* x; is however confusing to many beginners: it seems to say that you are declaring x to be of type `double*'. This is correct, but the obvious generalization `double* x,y;' declares x to be of type `double*', but y to be of type `double'. double *x; is therefore my preferred way of writing it. double *x,y,*z; defines x and z to be pointers to doubles, and y to be a double. Cheers Tanmoy Note: To be precise, my statements are wrong. `Tokens' are formed from `prerocessing tokens', and it is the latter which need to be separated by whitespace if necessary. Because of the # preprocessing operator and special meaning of end-of-line in the preprocessing directives, whitespace cannot be _completely_ ignored when outside of pp-tokens. -- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242) Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87544-0285,USA H:#3,802,9 St,NM87545 Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>, <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/ internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html> fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
Technical Details
Message-ID:
<42vcj5$aig@newshost.lanl.gov>Path:
arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoyReferences:
<9a7cb$d1625.8d@news.tcsmgmt.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoy From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) Newsgroups: comp.os.ms-windows.programmer.tools.mfc,comp.os.ms-windows.programmer.win32,comp.lang.c,comp.lang.c++ Subject: Re: Newbie pointer question Date: 10 Sep 1995 18:59:49 GMT Organization: Los Alamos National Laboratory Distribution: world Message-ID: <42vcj5$aig@newshost.lanl.gov> References: <9a7cb$d1625.8d@news.tcsmgmt.com> NNTP-Posting-Host: qcd.lanl.gov