Download Programming in C Language Question and Answers PDF

TitleProgramming in C Language Question and Answers
TagsPointer (Computer Programming) C (Programming Language) Subroutine Array Data Structure Variable (Computer Science)
File Size1.1 MB
Total Pages19
Document Text Contents
Page 1

Page 19


C is not C++. Typedef names are not automatically generated for structure tags.

105. Why can’t we compare structures?

There is no single, good way for a compiler to implement structure comparison which is

consistent with C‘s low-level flavor. A simple byte-by-byte comparison could founder on

random bits present in unused ―holes‖ in the structure (such padding is used to keep the

alignment of later fields correct). A field-by-field comparison might require unacceptable

amounts of repetitive code for large structures.

106. How are structure passing and returning implemented?

Ans: When structures are passed as arguments to functions, the entire structure is typically

pushed on

the stack, using as many words as are required. Some compilers merely pass a pointer to the

structure, though they may have to make a local copy to preserve pass-by-value semantics.

Structures are often returned from functions in a location pointed to by an extra,compilersupplied

―hidden‖ argument to the function. Some older compilers used a special,static location

for structure returns, although this made structure-valued functions non-reentrant, which ANSI C


Typewritten text
C Programs Online

Similer Documents