Voila!!!
Code:
#include <stdio.h>
#include <stdlib.h>
#define YES 1
#define NO 0 // not used
struct data {
char* text;
int bold, italic, underline;
};
void createPage( struct data *);
int main(void) {
char buff[BUFSIZ];
struct data myStructArray[20];
// struct data *st_ptr;
// st_ptr = &myStructArray[20]; // points off the end of the array
int response;
printf( "Please enter a line of text: " );
fgets( buff, BUFSIZ, stdin );
// you might want to remove the \n which fgets writes into buff
myStructArray[0].text = malloc( 100 ); // allocate space
strcpy( myStructArray[0].text, buff );
while ( 1 ) {
// Process text?
printf( "\nDo you want text to be bold?[1/0] " );
fgets( buff, BUFSIZ, stdin );
sscanf( buff, "%d", &response );
if ( response == YES ) {
//* Assign value of text to bold address *//
myStructArray[0].bold = YES;
puts( "Text will be in Bold" );
break;
} else
break;
}
createPage( myStructArray );
return 0;
}
void createPage( struct data *a) {
/* Create the output file */
FILE* outFile;
outFile = fopen( "phaseOne.html","w" );
/* All HTML files must start with this tag. */
fprintf( outFile,"<html>\n" );
if ( a->bold == YES ) {
fprintf( outFile,"<b>" );
}
/* Write to the file HTML representing a line of text. */
fprintf( outFile,"<p>" );
fprintf( outFile,"%s",a->text );
fprintf( outFile,"</p>\n" );
/* Write to the file HTML representing a line of bold text. */
if ( a->bold == YES ) {
fprintf( outFile,"</b>\n" );
}
/* All HTML files must end with this tag. */
fprintf( outFile,"</html>\n" );
/* Close the output file */
fclose( outFile );
}