Friday, July 29, 2016

C Basics - Identifiers in C

"Identifiers" or "symbols" are the names you supply for variables, types, functions, and labels in your program.

An Identifier can only have alphanumeric characters( a-z , A-Z , 0-9 ) and underscore( _ ).

The first character of an identifier name must be a nondigit (that is, the first character must be an underscore or an uppercase or lowercase letter).

No commas or blanks are allowed. No special symbol other than an underscore can be used.

Identifier names must differ in spelling and case from any keywords. You cannot use keywords as identifiers;

Identifier is case sensitive. That is, int result; and int RESULT; is recognized as a separate identifier.


#include <stdio.h>

int main()
{
    int result;

    result = printf("Hello World\n" );
    
    return result;
}

In the above example, result is an identifier for an integer variable, and main and printf are identifier names for functions.

A special kind of identifier, called a statement label, can be used in goto statements.



Related topics:
Tokens in C   |   Character Set in C   |   White Space Characters in C   |   Trigraph Characters in C   |   Extended Characters in C   |   Escape Sequence in C   |   Comments in C   |   Keywords in C   |   Declaration in C

List of topics: C Programming

No comments:

Post a Comment