| Author |
Message |
Simon Lewis *nix forums beginner
Joined: 18 Jun 2006
Posts: 1
|
Posted: Sun Jun 18, 2006 8:23 pm Post subject:
Re: sizeof 'a' returns 4
|
|
|
Frederick Gotham <fgothamNO@SPAM.com> writes:
| Quote: | Richard Heathfield posted:
Frederick Gotham said:
posted:
Hello
I've got a simple question regarding sizeof operator.
why sizeof 'a' return 4?
(Note the argument is without parenthesis)
If anybody is so kind to answer ...
TIA
typedef T double;
Syntax error.
So as not to clutter the newsgroup, I would request in future that, if
you choose to scrutanise and correct my code, that you correct the error
rather than simply indicate that an error is present -- it will be of
benefit to us all.
typedef double T;
Another thing, and this is your own perogative of course, maybe you'd
like to be more "social" about how you offer your counsel? It's pretty
|
Some chance.
Just google up some examples of his "help". Certainly seems to think
he's something special : but all I can see are self grandizing smart ass
comments generally designed to bemuse the newbie. Aspergers is a great
description IMO. |
|
| Back to top |
|
 |
Keith Thompson *nix forums Guru
Joined: 28 Feb 2005
Posts: 5173
|
Posted: Sun Jun 18, 2006 8:37 pm Post subject:
Re: sizeof 'a' returns 4
|
|
|
Frederick Gotham <fgothamNO@SPAM.com> writes:
| Quote: | posted:
I've got a simple question regarding sizeof operator.
why sizeof 'a' return 4?
(Note the argument is without parenthesis)
If anybody is so kind to answer ...
TIA
typedef T double;
unsigned SizeOf( T const t )
{
const char * const current = (const char*)&t;
const char * const next = (const char*)(&t + 1);
return next - current;
}
|
Was that supposed to be posted to a different thread? It doesn't seem
to have any relationship to the original question (which is question
8.9 of the comp.lang.c FAQ).
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this. |
|
| Back to top |
|
 |
Default User *nix forums Guru
Joined: 21 Feb 2005
Posts: 1159
|
Posted: Sun Jun 18, 2006 8:38 pm Post subject:
Re: sizeof 'a' returns 4
|
|
|
Frederick Gotham wrote:
| Quote: | Kenny McCormack posted:
|
[blither blather]
| Quote: | I'm not sure I understand what you're getting as... but are you
suggesting that this newsgroup bears some sort of association with
Asperger Syndrome?
|
Kenny is a troll, whose intention is disrupt the newsgroup. Just ignore
him. If you use a killfile, he's a good candidate.
Brian |
|
| Back to top |
|
 |
Kenny McCormack *nix forums Guru
Joined: 24 Mar 2005
Posts: 657
|
Posted: Sun Jun 18, 2006 10:41 pm Post subject:
Re: sizeof 'a' returns 4
|
|
|
In article <4flrtoF1jb96hU1@individual.net>,
Default User <defaultuserbr@yahoo.com> wrote:
| Quote: | Frederick Gotham wrote:
Kenny McCormack posted:
[blither blather]
I'm not sure I understand what you're getting as... but are you
suggesting that this newsgroup bears some sort of association with
Asperger Syndrome?
Kenny is a troll, whose intention is disrupt the newsgroup. Just ignore
him. If you use a killfile, he's a good candidate.
|
Man, you guys must really be worried.
Your responses are sooooo predictable. |
|
| Back to top |
|
 |
Kenny McCormack *nix forums Guru
Joined: 24 Mar 2005
Posts: 657
|
Posted: Sun Jun 18, 2006 10:42 pm Post subject:
Re: sizeof 'a' returns 4
|
|
|
In article <87irmyp613.fsf@gmail.com>,
Simon Lewis <simonlewis2001@gmail.com> wrote:
....
| Quote: | Some chance.
Just google up some examples of his "help". Certainly seems to think
he's something special : but all I can see are self grandizing smart ass
comments generally designed to bemuse the newbie. Aspergers is a great
description IMO.
|
So true. So true. Welcome to the Light Side. |
|
| Back to top |
|
 |
Nelu *nix forums beginner
Joined: 19 Jun 2006
Posts: 1
|
Posted: Mon Jun 19, 2006 12:00 am Post subject:
Re: sizeof 'a' returns 4
|
|
|
gazelle@xmission.xmission.com (Kenny McCormack) writes:
| Quote: | In article <4flrtoF1jb96hU1@individual.net>,
Default User <defaultuserbr@yahoo.com> wrote:
Frederick Gotham wrote:
Kenny McCormack posted:
[blither blather]
I'm not sure I understand what you're getting as... but are you
suggesting that this newsgroup bears some sort of association with
Asperger Syndrome?
Kenny is a troll, whose intention is disrupt the newsgroup. Just ignore
him. If you use a killfile, he's a good candidate.
Man, you guys must really be worried.
Your responses are sooooo predictable.
|
Just a general observation: when the teacher repeats the rules he's
only predictable if the pupil learnt them but doesn't give a damn
about them. That makes a brat... a modern time \sout{rock'n'roll}
troll. Some people grow up, eventually.
--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...) |
|
| Back to top |
|
 |
Barry Schwarz *nix forums Guru
Joined: 09 Apr 2005
Posts: 390
|
Posted: Mon Jun 19, 2006 12:22 am Post subject:
Re: sizeof 'a' returns 4
|
|
|
On Sun, 18 Jun 2006 13:37:03 GMT, Frederick Gotham
<fgothamNO@SPAM.com> wrote:
| Quote: | posted:
Hello
I've got a simple question regarding sizeof operator.
why sizeof 'a' return 4?
(Note the argument is without parenthesis)
If anybody is so kind to answer ...
TIA
typedef T double;
unsigned SizeOf( T const t )
{
const char * const current = (const char*)&t;
const char * const next = (const char*)(&t + 1);
return next - current;
}
|
Your typedef has a syntax error.
What does the size of a double have to do with the original question?
Did you mean
typedef int T;
If the OP realized that 'a' was of type int (and not char), he
probably wouldn't have asked the question in the first place.
Remove del for email |
|
| Back to top |
|
 |
Dik T. Winter *nix forums Guru
Joined: 23 Feb 2005
Posts: 327
|
Posted: Mon Jun 19, 2006 12:38 am Post subject:
Re: sizeof 'a' returns 4
|
|
|
In article <87irmyp613.fsf@gmail.com> Simon Lewis <simonlewis2001@gmail.com> writes:
| Quote: | Frederick Gotham <fgothamNO@SPAM.com> writes:
Richard Heathfield posted:
Frederick Gotham said:
posted:
....
why sizeof 'a' return 4?
....
typedef T double;
Syntax error.
So as not to clutter the newsgroup, I would request in future that,
....
Some chance.
Just google up some examples of his "help".
|
Well, if somebody posts a follow-up with completely irrelevant information,
you can expect some comments. I will give full comments:
Interchange 'T' and 'double'
| Quote: | unsigned SizeOf( T const t )
{
const char * const current = (const char*)&t;
const char * const next = (const char*)(&t + 1);
return next - current;
}
|
This does not answer the original question (why sizeof 'a' == 4). I think
it was intended as a response to a question in another thread about a user
replacement of sizeof. And it also fails as that. It returns
sizeof (double). So can Frederick Gotham explain the intent of his
article?
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/ |
|
| Back to top |
|
 |
Old Wolf *nix forums Guru
Joined: 20 Feb 2005
Posts: 679
|
Posted: Mon Jun 19, 2006 1:03 am Post subject:
Re: sizeof 'a' returns 4
|
|
|
Richard Heathfield wrote:
| Quote: | Frederick Gotham said:
typedef T double;
Syntax error.
|
Interesting (?) fact I encountered while verifying your answer:
typedef double;
is NOT a syntax error; nor is:
double; |
|
| Back to top |
|
 |
lovecreatesbeauty *nix forums Guru Wannabe
Joined: 21 Feb 2005
Posts: 193
|
Posted: Mon Jun 19, 2006 3:17 am Post subject:
Re: sizeof 'a' returns 4
|
|
|
Old Wolf wrote:
| Quote: |
Interesting (?) fact I encountered while verifying your answer:
typedef double;
is NOT a syntax error; nor is:
double;
|
Does following answer the question?
lovecreatesbeauty
/*quoting begins*/
A.2.2 Declarations
(6.7) declaration-specifiers:
storage-class-specifier declaration-specifiers(opt)
type-specifier declaration-specifiers(opt)
<snip>
(6.7.1) storage-class-specifier:
typedef
<snip>
(6.7.2) type-specifier:
<snip>
double
<snip>
/*quoting ends*/ |
|
| Back to top |
|
 |
Old Wolf *nix forums Guru
Joined: 20 Feb 2005
Posts: 679
|
Posted: Mon Jun 19, 2006 3:25 am Post subject:
Re: sizeof 'a' returns 4
|
|
|
lovecreatesbeauty wrote:
| Quote: | Old Wolf wrote:
Interesting (?) fact I encountered while verifying your answer:
typedef double;
is NOT a syntax error; nor is:
double;
Does following answer the question?
|
What question? |
|
| Back to top |
|
 |
Harald van D議k *nix forums Guru Wannabe
Joined: 06 Feb 2006
Posts: 123
|
Posted: Mon Jun 19, 2006 6:27 am Post subject:
Re: sizeof 'a' returns 4
|
|
|
Old Wolf wrote:
| Quote: | Richard Heathfield wrote:
Frederick Gotham said:
typedef T double;
Syntax error.
Interesting (?) fact I encountered while verifying your answer:
typedef double;
is NOT a syntax error; nor is:
double;
|
Right, it's a constraint violation, and not a syntax error, because a
type-specifier followed by a semicolon can be a valid declaration:
struct S { /* ... */ };
Another interesting fact (? here too):
struct S { /* ... */ } typedef;
is allowed as well, and does not define any variable. |
|
| Back to top |
|
 |
neutron*star *nix forums Guru
Joined: 21 Feb 2005
Posts: 2039
|
Posted: Mon Jun 19, 2006 6:49 am Post subject:
Re: sizeof 'a' returns 4
|
|
|
Frederick Gotham said:
| Quote: | Richard Heathfield posted:
Frederick Gotham said:
posted:
Hello
I've got a simple question regarding sizeof operator.
why sizeof 'a' return 4?
(Note the argument is without parenthesis)
If anybody is so kind to answer ...
TIA
typedef T double;
Syntax error.
So as not to clutter the newsgroup, I would request in future that, if
you choose to scrutanise and correct my code, that you correct the error
rather than simply indicate that an error is present -- it will be of
benefit to us all.
|
Sorry, Frederick. I thought I had given sufficient information, given the
limited number of ways in which it could be wrong.
| Quote: | Another thing, and this is your own perogative of course, maybe you'd
like to be more "social" about how you offer your counsel?
|
Your original reply was not only an attempt to spoonfeed a homework answer
(always a bad idea) but was also an incorrect answer to the wrong question,
and it would not even compile.
This is your own prerogative, of course, but maybe you'd like to focus on
getting your own house in order before you start telling other people what
to write?
| Quote: | It's pretty
clear that my error was more a question of "getting things muddled up"
rather than having a deficit of proficiency.
|
My comment that your code had a syntax error was not a claim that you had a
"deficit of proficiency". It was a comment that your code had a syntax
error. These are not the same thing. But you can try for "deficit of
proficiency" if you like.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously) |
|
| Back to top |
|
 |
Mark McIntyre *nix forums Guru
Joined: 16 Feb 2005
Posts: 1564
|
Posted: Mon Jun 19, 2006 9:17 pm Post subject:
Re: sizeof 'a' returns 4
|
|
|
On Sun, 18 Jun 2006 22:23:20 +0200, in comp.lang.c , Simon Lewis
<simonlewis2001@gmail.com> wrote:
| Quote: | Just google up some examples of his "help". Certainly seems to think
he's something special : but all I can see are self grandizing smart ass
comments generally designed to bemuse the newbie. Aspergers is a great
description IMO.
|
Congrats, you get the fsckwit of the week award.
--
Mark McIntyre
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan |
|
| Back to top |
|
 |
Mark McIntyre *nix forums Guru
Joined: 16 Feb 2005
Posts: 1564
|
Posted: Mon Jun 19, 2006 9:18 pm Post subject:
Re: sizeof 'a' returns 4
|
|
|
On Sun, 18 Jun 2006 22:41:39 +0000 (UTC), in comp.lang.c ,
gazelle@xmission.xmission.com (Kenny McCormack) wrote:
| Quote: | In article <4flrtoF1jb96hU1@individual.net>,
Default User <defaultuserbr@yahoo.com> wrote:
Frederick Gotham wrote:
Kenny McCormack posted:
[blither blather]
I'm not sure I understand what you're getting as... but are you
suggesting that this newsgroup bears some sort of association with
Asperger Syndrome?
Kenny is a troll, whose intention is disrupt the newsgroup. Just ignore
him. If you use a killfile, he's a good candidate.
Man, you guys must really be worried.
Your responses are sooooo predictable.
|
*replonk*
--
Mark McIntyre
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|