Interview Questions

How are portions of a program disabled in demo versions?

C Interview Questions and Answers


(Continued from previous question...)

How are portions of a program disabled in demo versions?

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
...
}

(Continued on next question...)

Other Interview Questions