Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Declaration: K&R

Tags:

c

variables

I was reading Chapter 2 of The C programming language by K&R : "Types, Operators & Expressions", section 2.4, where in I found the below statements being made:

If the variable in question is not automatic, the initialization is done once only, conceptually before the program starts executing, and 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.

The above lines aren't too clear what do they mean?

like image 718
Miss J. Avatar asked Nov 06 '14 14:11

Miss J.


People also ask

What is a K-1 declaration?

The K-1 declaration is a letter that addresses all of the above requirements. Your K-1 declaration should describe how you met and what caused you to fall in love. It should document specific dates and describe your in-person meeting (s) with each other. Make an effort to ensure that your K-1 declaration includes the following:

What is a K&R function declaration?

By C89, the notion of a function prototype, which also specifies the types of the parameters (and, implicitly, their number) had been added. Since a prototype is also a type of function declaration, the unofficial term "K&R function declaration" is sometimes used for a function declaration that is not also a prototype.

How do I declare my intent to get married on K1?

Declare your intent to get married within 90 days of the K-1 entering the U.S. CitizenPath has a downloadable sample K-1 declaration that you can use as an example for your own statement. Each declaration is unique, and yours should contain your personal story.

When do I need to make declarations on the customs declaration service?

You will need to make declarations on the Customs Declaration Service if you move goods moving from Great Britain to Northern Ireland. There are some limited exceptions when you need to submit an export declaration on the Customs Declaration Service for a movement of goods from Northern Ireland to Great Britain.


1 Answers

int a = 5;
int b = a; //error, a is not a constant expression

int main(void)
{
  static int c = a; //error, a is not a constant expression
  int d = a; //okay, a don't have to be a constant expression
  return 0;
}

only d is a automatic variable and so only d is allowed to get initialized with an other variable.

like image 152
mch Avatar answered Oct 05 '22 19:10

mch