COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button
C++ LANGUAGE #DEFINE PREPROCESSOR
The #define Preprocessor
The #define preprocessor directive creates symbolic
constants. The symbolic constant is called a macro and
the general form of the directive is:
#define macro-name replacement-text
When this line appears in a file, all subsequent occurrences
of macro in that file will be replaced by replacement-text
before the program is compiled. For example:
#include <iostream>
using namespace std;
#define PI 3.14159
int main ()
{
cout << "Value of PI :" << PI << endl;
return 0;
}
35. PREPROCESSOR
test.p. Now, if you check test.p, it will have lots of information
and at the bottom, you will find the value replaced as follows:
$gcc -E test.cpp > test.p
...
int main ()
{
cout << "Value of PI :" << 3.14159 << endl;
return 0;
}
No comments:
Post a Comment