Ansi C Interview Questions and answers
1.What is the “ANSI C Standard?”
A:In 1983, the American National Standards Institute commissioned a
committee, X3J11, to standardize the C language. After a long,
arduous process, the committee’s work was finally ratified as an
American National Standard, X3.159-1989, on December 14, 1989, and
published in the spring of 1990. The Standard has also been
adopted as ISO/IEC 9899:1990.
2.How can I get a copy of the Standard?
A:Copies are available from the American National Standards Institute
in New York, or from Global Engineering Documents in Irvine, CA.
See the unabridged list for addresses.
3.Does anyone have a tool for converting old-style C programs to ANSI
C, or for automatically generating prototypes?
4.What’s the difference between “char const *p” and “char * const p”?
A:The former is a pointer to a constant character; the latter is a
constant pointer to a character.
5. My ANSI compiler complains about a mismatch when it sees
extern int func(float);
int func(x)
float x;
{…
A:You have mixed the new-style prototype declaration
“extern int func(float);” with the old-style definition
“int func(x) float x;”. The problem can be fixed by using either
new-style (prototype) or old-style syntax consistently.
5.I’m getting strange syntax errors inside code which I’ve #ifdeffed
out.
A:Under ANSI C, #ifdeffed-out text must still consist of “valid
preprocessing tokens.” This means that there must be no
unterminated comments or quotes (i.e. no single apostrophes), and
no newlines inside quotes.
6.Can I declare main as void, to shut off these annoying “main
returns no value” messages?
A: No.
7.Why does the ANSI Standard not guarantee more than six monocase
characters of external identifier significance?
A:The problem is older linkers which cannot be forced (by mere words
in a Standard) to upgrade.
8.Whatever happened to noalias?
A:It was deleted from the final versions of the standard because of
widespread complaint and the near-impossibility of defining it
properly.
9.What are #pragmas and what are they good for?
A:The #pragma directive provides a single, well-defined “escape
hatch” which can be used for extensions.
No comments:
Post a Comment