List Info

Thread: Re: Mentor for C self study wanted




Re: Mentor for C self study wanted
country flaguser name
United Kingdom
2007-10-23 17:36:40
cpghost wrote:

> There's a mismatch here: scanf("%d", ...)
expects a pointer to int,
> while &nnote is a pointer to a short. Normally, an
int occupies more
> bytes in memory than a short (typically sizeof(int) ==
4 on 32bit
> platforms, and sizeof(int) == 8 on 64bit platforms;
while typically
> sizeof(short) == 2).

I think short and int stay the same on both 32 and 64 bit
platforms, 
while it's only long that gets bumped to 8 bytes.  At least
that seems 
to be what happens on FreeBSD amd64.

--
Bruce
_______________________________________________
freebsd-questionsfreebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-que
stions
To unsubscribe, send any mail to
"freebsd-questions-unsubscribefreebsd.org"

Re: Mentor for C self study wanted
country flaguser name
United States
2007-10-23 21:00:42
Bruce Cran wrote:
> cpghost wrote:
>
>> There's a mismatch here: scanf("%d", ...)
expects a pointer to int,
>> while &nnote is a pointer to a short. Normally,
an int occupies more
>> bytes in memory than a short (typically sizeof(int)
== 4 on 32bit
>> platforms, and sizeof(int) == 8 on 64bit platforms;
while typically
>> sizeof(short) == 2).
>
> I think short and int stay the same on both 32 and 64
bit platforms, 
> while it's only long that gets bumped to 8 bytes.  At
least that seems 
> to be what happens on FreeBSD amd64.
>
> -- 
> Bruce
No... you're only safe using int32, int64, etc. Just for
grins try 
compiling a program like this:

#include <stdio.h>

int main() {
    printf("%dn", sizeof(int));
    return 0;
}
_______________________________________________
freebsd-questionsfreebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-que
stions
To unsubscribe, send any mail to
"freebsd-questions-unsubscribefreebsd.org"

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )