#include #include #include #define STL 1 #define Q 1 #ifdef STL #include #endif #ifdef Q #include #endif void c(const char * name, const char *type, const char * date, const char *phone, const char * about) { char * cstr; int length=snprintf(NULL, 0, "

Table of Values

\n" "\n" "
NameTypeDatePhone\n" "
%s%s%s%s\n" "

About %s

\n" "%s\n", name, type, date, phone, name, about); cstr=(char *)malloc(length+1); sprintf(cstr, "

Table of Values

\n" "\n" "
NameTypeDatePhone\n" "
%s%s%s%s\n" "

About %s

\n" "%s\n", name, type, date, phone, name, about); printf(cstr); } #ifdef STL void stl(const char *name, const char *type, const char * date, const char *phone, const char * about) { string stlstr="

Table of Values

\n" "\n" "
NameTypeDatePhone\n" "
"; stlstr+=name; stlstr+=""; stlstr+=type; stlstr+=""; stlstr+=date; stlstr+=""; stlstr+=phone; stlstr+="\n

"; stlstr+="About "; stlstr+=name; stlstr+="

\n"; stlstr+=about; stlstr+="\n"; cout << stlstr; } #endif #ifdef Q void qt(const char *name, const char *type, const char * date, const char *phone, const char * about) { QString qtstr; qstr.sprintf( "

Table of Values

\n" "\n" "
NameTypeDatePhone\n" "
%s%s%s%s\n" "

About %s

\n" "%s\n", name, type, date, phone, name, about); cout << qtstr; } #endif int main(int argc, char ** argv) { const char * name="David", *type="Home", *date="Oct 2, 2002", *phone="123-123-1234", *about="This would normally be the home " "phone number of David. But if you can't guess the number " "is a fake."; switch(argc) { case 1: c(name, type, date, phone, about); break; case 2: #ifdef STL stl(name, type, date, phone, about); #endif break; case 3: #ifdef Q qt(name, type, date, phone, about); #endif break; } return 0; }