Showing posts with label Initialize. Show all posts
Showing posts with label Initialize. Show all posts

Friday, 11 November 2011

Predict the output or error(s) for the following:

#include<stdio.h>

main()

{

struct xx


{


      int x=3;


      char name[]="hello";


 };


struct xx *s;


printf("%d",s->x);


printf("%s",s->name);


}

Answer:

Compiler Error


Explanation:

Saturday, 5 November 2011

Do variables need to be initialized?

No. All variables should be given a value before they are used, and a good compiler will help you find variables that are used before they are set to a value. Variables need not be initialized, however. Variables defined outside a function or defined inside a function with the static keyword are already initialized to 0 for you if you do not explicitly initialize them.

Automatic variables are variables defined inside a function or block