//demo2.c

//When given the task of developing the user interface for a text based CAD 
//program we also create a more complicated abstraction to use 

void print_number(int);  //Not filled in here

//this allows us to do:

int length = 4;
int height = 3;

void print_length(void){
	printf("rectangle1 is ");
	print_number(length);
	printf(" inches long");}

void print_height(void){
	printf("rectangle1 is ");
	print_number(height);
	printf(" inches high");}


//We can see a pattern here, so obviously there is something to be abstracted, 
//but rather then just abstracting it for these 2 cases, step back and think 
//about what we are trying to do.

//We want to write a language in which we can easily develop user 
//interfaces.  Thus a improvement would be to implement a new "print_string" 
//function, which we'll now call printf, that will be able to accept 
//string and possibly some number parameters, and will substitute numbers
//for any "%n"'s in the string.

//so
int variable = 8;
printf("text%ntext", variable);

//produces
//text8text

//this reduces our procedures to:

printf("the rectange1 is %n inches high", height);
printf("the rectange1 is %n inches long", length);

//We have now designed a vastly suprior language for designing textual user 
//interfaces, which is merely a extention to the original C language.  What 
//was once a large programming task, is now easy.  all because we were 
//allowed to add to the original programming interface, because C does not 
//have as many constraints as sed does.

//note that this sublangauge is usefull enough that it is included in the 
//standard C libraries for you as "printf", and does even more then we have
//eluded to here.






