C Standard Questions


This page is a collection of questions regarding the ISO standard for the C language.

The fact that a programming language is "standardized" doesn't mean there are no problems left to solve or questions left to ask. Even after close reading of a standard there often are some unclear points, especially if one isn't use to interprete the language used in standardization documents (the so-called "standardese").

While I am quite experienced in writing C programs, and while I did study the standard quite closely when I was employed to write C compilers, I am not an official spokesperson of either ISO, ANSI, or anybody else. All answers summarized on this page have been derived by discussions (usually on Usenet) with other people, usually far more knowledgeable than yours truly.

Other Sources of Answers

The 1990 Standard
Of course the prime source to look for answers about C is the language standard itself. It is not available in electronic form, but can be ordered from ISO, either directly on the Web or by writing to
                        ISO Sales
		        Case Postale 56
		CH-1211 Genève 20
The standard's official number is ISO/IEC 9899:1990(E).

The Rationale
The original ANSI version of the standard, which later was adopted by ISO, was accompanied by a document called the "rationale". It never was part of the standard (it was included "for information only"), and nowadays it isn't distributed with the standard anymore. The rationale explains why the choices made in the standard were made that way instead of some other way. It is available in electronic form, and is a very enlightening read if you're concerned about standard C.

Technical Corrigenda
Like any other ISO standard, the C standard is being reviewed continuously. So far, these reviews have produced two documents clarifying obscure points in the standard, known as "Technical Corrigenda". As an exception to ISO's distribution rules, both the Technical Corrigendum 1 and the Technical Corrigendum 2 are available on the Web. Lysator in Sweden also has summaries for TC1 and TC2.

Normative Addendum 1
Besides these technical corrigenda, which basically do not change the C standard except in minor ways, there's also a "Normative Addendum 1" which extends the standard considerably, especially the definitions for wide-character I/O. This document is about 50 pages thick and also can be ordered from ISO. Only a brief description of its contents is available on the Web.

Programming in C
This is a web site put together by Jutta Degener. It deals with a multitude of aspects of the C language, including its history and related laguages. (You might note that quite a few of the other links on my page here lead to this site.) Highly recommended!

The comp.lang.c FAQ
The list of frequently asked questions (FAQ) of the newsgroup comp.lang.c is an excellent source of answers concerning both advanced and trivial aspects of the C language. Its plain-text version is available via ftp from rtfm.mit.edu (252 kB), but there's also an HTML version, and the FAQ's maintainer has recently published it as a book.

The Ten Commandments for C Programmers
A classic of hacker lore. All of its advice is correct, and following it to the letter is most assuredly not a bad idea. (Some of the annotations are no longer valid for the new C standard.)

The ISO Committee Draft on the new C9X Standard
In the late ninteen-nineties, the C standard has been extensively revised. This work culminated in a new standard for the language, ratified by ISO in 1999 (and hence its document number should be ISO/IEC 9899:1999). The above link takes you to my summary of the most important changes from the C language as we have known it until now. The page also contains links to online versions of the Committee Draft, which is an early version of this new standard. This is not the final standard, which may differ substantially from this document, but it may give you a good idea what has changed and what hasn't.

If you have questions about floating point arithmetic etc., check out the following documents:

IEEE Standards for Floating-Point Arithmetic
There are two different IEEE standards for floating-point arithmetic. They have numbers 754 and 854. Usually, people talk about the 754 standard, which is document ANSI/IEEE Std 754-1985 and has also been published as ACM SIGPLAN Notices 22(2), pp. 9-25, Feb. 1987.

The ANSI/IEEE Std 854-1987 standard allows both binary and decimal bases for floating-point values, and it doesn't specify how floating-point numbers are encoded (i.e. the bit layout).

The ISO standard corresponding to ANSI 754 actually is an IEC standard: IEC 559:1989.

What Every Computer Scientist Should Know About Floating-Point Arithmetic
This is an excellent article by David Goldberg which appeared in ACM Computing Surveys 23(1), pp. 5 - 48, March 1991. (Warning: the above link is very slow for me, you might be better off looking it up in Comp. Surveys -- at least if you're in Europe. YMMV.)

Language Issues and Floating-Point Arithmetic
There also is the ISO standard on "Language-Independent Arithmetic" (ISO/IEC 10967-1:1994(E)) which has impacts on C implementations if they claim to comply to this standard. This is one of the few ISO standards that is available on the net!


Any references to the C standard ISO/IEC 9899:1990(E) are abbreviated [ISO] below. References [TC1] and [TC2] refer to the on-line summaries mentioned above.

The Questions

String Initializations
If an (automatic) array is initialized by a string literal that has fewer characters than the array has elements, what happens with the excess array elements?

Getting Interactive Input
Properly handling user interaction and getting input safely is not as easy as it looks. This page gives some hints and shows some pitfalls of C's input/output library.

Macro Call as Macro Argument
If a macro call is an argument to another macro which doesn't use this argument in its replacement list, is the macro expanded all the same?

I have a Question...

If you still have questions, follow the steps below in the given order:

  1. Read your favorite C book. But make sure it's a good book. Kernighan & Ritchie or Harbison & Steele are recommended, Schildt's books are just trash can fodder.
  2. Read the comp.lang.c FAQ.
  3. Read the "Rationale".
  4. Buy the standard and read it.
  5. Ask your question on the newsgroup comp.lang.c.
  6. Ask your question on the newsgroup comp.std.c.
  7. Submit a request for clarification to the ISO workgroup on the C programming language (ISO JTC1/SC22/WG14).

Good luck!