How are portions of a program disabled in demo versions? Ans. If you are distributing a demo version of your program, the preprocessor can be used to enable or disable portions of your program. The following portion of code shows how this task is accomplished, using the preprocessor directives #if and #endif: int save_document(char* doc_name) { #if DEMO_VERSION printf('Sorry! You can't save documents using the DEMO version of this program!\n'); return(0); #endif ... } When you are compiling the demo version of your program, insert the line #define DEMO_VERSION and the preprocessor will include the conditional code that you specified in the save_document() function. This action prevents the users of your demo program from saving their documents. As a better alternative, you could define DEMO_VERSION in your compiler options when compiling and avoid having to change the source code for the program. This technique can be applied to many different situations. For instance, you might be writing a program that will support several operating systems or operating environments. You can create macros such as WINDOWS_VER, UNIX_VER, and DOS_VER that direct the preprocessor as to what code to include in your program depending on what operating system you are compiling for. - Study24x7
Social learning Network
23 Mar 2023 12:07 PM study24x7 study24x7

How are portions of a program disabled in demo versions? Ans. If you are distributing a demo version of your program, the preprocessor can be used to enable or disable portions of your program. The following portion of code shows how this task is accomplished, using the preproce...

See more

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles