%{ #define YY_INPUT(buf,result,max_size) \ { int digit ; \ int c = getc( yyin ) ; \ result = c == EOF ? 0 : 1 ; \ if( c == '%' ) { \ c = getc( yyin ) ; \ digit = c >= 'A' ? (( c & 0xdf ) - 'A' ) + 10 : c - '0' ; \ digit *= 16 ; \ c = getc( yyin ) ; \ digit += c >= 'A' ? (( c & 0xdf ) - 'A' ) + 10 : c - '0' ; \ buf[0] = (char) digit ; \ } \ else if( c == '+' ) \ buf[0] = ' ' ; \ else \ buf[0] = (char) c ; \ } int ans2a = 0, ans2b = 0, ans2c = 0, ans2d = 0 , ans2e = 0 ; int correct = 1 ; %} WS [ \t] %% "answer6-2a=T"\&? { ans2a = 1 ; } "answer6-2b=T"\&? { ans2b = 1 ; } "answer6-2c=T"\&? { ans2c = 1 ; } "answer6-2d=T"\&? { ans2d = 1 ; } \n {} %% #include main() { yylex() ; } yywrap() { if( ans2a && ans2b && ans2c && !ans2d ) send_file( "ans6-2.right" ) ; else { printf( "Content-type: text/html\n\n" ) ; printf( "\n\n" ) ; printf( "Experimental C Tutorial - Part 6-2\n" ) ; printf( "\n\n" ) ; printf( "

Sorry, you answered one or more incorrectly

\n" ) ; if( !ans2a ) { printf( "We can have pointer to any type of data in C.\n" ) ; printf( "So a pointer to an integer is perfectly valid.\n" ) ; } if( !ans2b ) { printf( "

If we declare a variable name with two stars\n" ) ; printf( "in front of it, then we have a pointer to a\n" ) ; printf( "pointer. While it may not seem useful now, it\n" ) ; printf( "turns out to be quite a helpful feature.\n" ) ; } if( !ans2c ) { printf( "

It is valid to combine the syntax of pointer\n" ) ; printf( "and array declarations. If we declare it like\n" ) ; printf( "

\nchar *names[100] ;\n
\nthen we are\n" ) ; printf( "creating an array of pointers to characters.\n" ) ; } if( ans2d ) { printf( "

Even though we can leave the size of the array\n" ) ; printf( "out in a parameter declaration, we must include it\n" ) ; printf( "in variable declarations.\n" ) ; } printf( "

Return and try again\n" ) ; printf( "\n" ) ; } return( 1 ) ; } send_file( s ) char *s ; { FILE *fp ; char buf[81] ; printf( "Content-type: text/html\n\n" ) ; fp = fopen( s, "r" ) ; if( fp ) { while( fgets( buf, 80, fp )) { printf( "%s", buf ) ; } fclose( fp ) ; } }