KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q41577: QuickC 2.00 README.DOC: Declaring and Initializing Arrays

Article: Q41577
Product(s): See article
Version(s): 2.00
Operating System(s): MS-DOS
Keyword(s): ENDUSER | | mspl13_c
Last Modified: 28-FEB-1989

The information below is taken from the QuickC Version 2.00 README.DOC
file, Part 2, "Notes on 'C for Yourself.'" The following notes refer
to specific pages in "C for Yourself."

Page 54  Declaring and Initializing Arrays

You can always initialize an array with constants. If you initialize
an automatic (local) array with variables or addresses that are
unknown to the compiler at compile time, you must include the size of
the array. For example:

#define FIVE 5
main()
{
  int i = 5;
  int abc[] = { 5, FIVE};  /* constants always work */
  int def[] = { i, i }     /* ERROR: variables in unsized array */
  int ghi[2] = {i, i }     /* sized array works */

Warning: The first edition of "The C Programming Language" by
Kernighan and Richie did NOT allow you to initialize automatic arrays.
The ANSI standard and the second edition of K&R make provision for
initialization by constants. Initializing an automatic array with
variables is a Microsoft extension to ANSI. If you plan to port your
program to another computer or operating system, these constructs may
not be portable. QuickC will issue a warning about initializing
automatic arrays at warning level three. The requirement for sized
arrays is unique to QuickC -- unsized arrays are accepted by the
Microsoft C Optimizing Compiler.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.