Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: memcpy not memcpying? Date: Sat, 02 Nov 2019 02:15:09 -0700 Organization: None to speak of Lines: 50 Message-ID: References: <2LVuF.7$BF1.0@fx26.iad> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="9098de3fd9a31fa536b44e8ea792881e"; logging-data="2716"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/qhs/diN+ccNb3Hc/0b5vz" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:gmkw35a5J3b4qn3x2ML8aqvyFL8= sha1:he1ogpndvdEGIxZcrrrLiyt+9CE= Xref: csiph.com comp.lang.c:147498 DFS writes: > On 11/1/2019 1:19 PM, Keith Thompson wrote: >> DFS writes: >> [...] >>> printf("%d\n",sizeof(char*)); >>> 8 >> >> sizeof yields a result of type size_t. Use "%zu", not "%d". > > tcc 0.9.26 Windows > > printf("%zu\n",sizeof(char*)); > zu Yes, if you have a pre-C99 implementation "%zu" might not work. (tcc is a compiler; it doesn't include a runtime library. It's probably using Microsoft's C library.) > printf("%d\n",sizeof(char*)); > 8 > > printf("%lu\n",sizeof(char*)); > 8 > > printf("%llu\n",sizeof(char*)); > 8 All those can work, but none of them are reliable. > printf("%f\n",sizeof(char*)); > 0.000000 > > printf("%s\n",sizeof(char*)); > (*.exe has stopped working) "8", "0.000000", and "... has stopped working" are all possible instances of undefined behavior. > https://codeforwin.org/2015/05/list-of-all-format-specifiers-in-c-programming.html Not a great source of information. For example, all it says about "%n" is that it prints nothing -- which is true, but not the point. (It takes a pointer argument and stores the number of characters printed so far in the object it points to. Some C libraries don't support "%n" because it's considered unsafe.) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */