Summary: How to Declare a Simple Variable

  1. Choose the type you need.

  2. Choose a name for the variable.

  3. Use this format for a declaration statement: type-specifier variable-name;. The type-specifier is formed from one or more of the type keywords. Here are some examples:

    int erest;
    unsigned short cash;
    
  4. To declare more than one variable of the same type, separate the variable names with commas:

    char ch, init, ans;
    
  5. You can initialize a variable in a declaration statement:

    float mass = 6.0E24;
    

Summary: Storage Classes

Keywords:

auto, extern, static, register

General Comments:

The storage class of a variable determines its scope, its linkage, and its storage duration. Storage class is determined both by where the variable is defined and by its associated ...

Get C Primer Plus®, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.