Declaring Variables - C Language Basics

C examples for Language Basics:Variable

Introduction

To declare a variable, start with the data type and then add the identifier, which is the name of the variable.

int myInt;

The variable name can have letters, numbers, and underscores, but it cannot start with a number.

It also cannot contain spaces or special characters and cannot be a reserved keyword.

int _myInt32; /* allowed */
int 32Int;    /* incorrect (starts with number) */
int my Int;   /* incorrect (contains space) */
int Int@32;   /* incorrect (contains special character) */
int return;   /* incorrect (reserved keyword) */

Related Tutorials