Friday 30 November 2012

what is the default type of function in c


The function type is not required by C. If no function
type is declared, the type defaults to
int. However, if no type is provided, the maintainer cannot determine

if you wanted to use the default (int) or if you simply

forgot to declare a type. To avoid this confusion,always declare the function type and do not use the default.



  • How ever this facility was removed in the improved version of c i.e in c99 and later versions and it is no more valid.

Wednesday 21 November 2012

some areas where unions are used


Unions are used frequently when specialized type conversions are needed because you can refer to the data held in the union in fundamentally different ways. For example, you might use a union to


manipulate the bytes that constitute a double in order to alter its precision or to perform some

unusual type of rounding.

Thursday 8 November 2012

difference between delarations and definitions

A declaration provides basic attributes of a symbol: its type and its name. 
A definition provides all of the details of that symbol--if it's a function, what it does; if it's a class, what fields and methods it has; if it's a variable, where that variable is stored. 
Often, the compiler only needs to have a declaration for something in order to compile a file into an object file, expecting that the linker can find the definition from another file.
 If no source file ever defines a symbol, but it is declared, you will get errors at link time complaining about undefined symbols.

 

format specifier %n


The %n Specifier:



The %n format specifier is different from the others. Instead of telling printf( ) to display
something, it causes printf( ) to load the integer variable pointed to by its corresponding argument
with a value equal to the number of characters that have been output. In other words, the value that
corresponds to the %n format specifier must be a pointer to a variable. After the call to printf( ) has
returned, this variable will hold the number of characters output, up to the point at which the %n
was encountered. Examine the next program to understand this somewhat unusual format code:





#include <stdio.h>
int main(void)
{
int count;
printf("this%n is a test\n", &count);
printf("%d", count);
return 0;

output:

this is a test
followed by the number 4.

Wednesday 7 November 2012

format specifier %p


Displaying an Address



If you want to display an address, use
%p. This format specifier causes printf( ) to display a
machine address in a format compatible with the type of addressing used by the computer.