Initialization of variables

Nasza ocena:

3
Wyświetleń: 511
Komentarze: 0
Notatek.pl

Pobierz ten dokument za darmo

Podgląd dokumentu
Initialization of variables - strona 1 Initialization of variables - strona 2

Fragment notatki:

Initialization of variables • A variable may also be initialized in its declaration • Syntax: type name = expression; • Examples: char esc = '\\'; int i = 7*8; int limit = MAXSIZE+1; float eps = 1.0e-5; char msg[] = "warning: "; • For not automatic variables: the initialization is done once, ”before the program starts” - the initializer must be a constant expression • An explicitly initialized automatic variable is initialized each time the function or block it is in is entered - the initializer may be any expression • External and static variables are initialized to zero • Non-initialized automatic variables have undefined (garbage) values • The qualifier const can be applied to the declaration of any variable to specify that its value will not be changed: const double pi = 3.1415926535897932; • For an array, the const qualifier means that the elements will not be changed ... zobacz całą notatkę



Komentarze użytkowników (0)

Zaloguj się, aby dodać komentarz