Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!buffer1.nntp.ams1.giganews.com!buffer2.nntp.ams1.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Sun, 09 Apr 2017 14:53:54 -0500 From: Gareth Owen Newsgroups: comp.lang.c Subject: Re: And they say C is obscure References: <20170409-035940.754.0@Peabody.ssl.astraweb.com> Date: Sun, 09 Apr 2017 20:53:54 +0100 Message-ID: <8760idxsq5.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:86sXD8iHmb2VE5rxa8J1d3rnqHU= MIME-Version: 1.0 Content-Type: text/plain Lines: 33 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-5mMQ0i0JZtyrzDOeenJA8c6sGkurZNP10GTJtfj57wMAEwG3Cjz9Ww2wTVQIxqunYSQJy7+VXGwisde!YL5CnIeguTmUs2qbZicWW3MIL9A7bw0tgmDJkK0r9arqkp+OIqjZ/maFrt2Um3fCnBNBrZk= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 1782 Xref: csiph.com comp.lang.c:107953 James Kuyper writes: > On 04/08/2017 11:59 PM, Peabody wrote: > ... >> And while I'm at it, let me ask how you would create an unsigned byte array >> exactly 2048 bytes long, and fill it with FFs. > > #include > > unsigned char array[2048]; > > memset(array, 0xFF, sizeof array); > > Note: the #include should be at file scope. The call to memset() must > occur inside a function. The declaration for array could occur either > inside or outside a function. *Warning for Peabody* void set_to_0xff(char array[2048]) { memset(array, 0xFF, sizeof array); } main() { char my_arr[2048]; set_to_0xff(my_arr); } will not work. A (IMHO truly horrible but mostly forgiveable) historical anomaly of the language design.