Tokens:


A token is a sequence of characters that is understood as a unit. They are the basic building blocks of a C program. Tokens supported in C include keywords, variables, constants, special characters, operators etc.


The compiler scans the text in your source code and converts them into tokens during compilation. Now let us consider a program

/* Prints a message */
#include<stdio.h>
main()
{
            Printf(“ I made a C program”);
}

This source code contains tokens such as #, include, main etc.The computer ignores the comment symbols and the text enclosed within it.


Tokens are useful for compiler to detect errors. When tokens are not arranged in a particular sequence, the compiler generates an error message.

Previous                                                                                      Next

Powered by Blogger.