Hello all,
Can some please show me how I can end a for loop with a character? Right now it ends with a blank line. I want it to end when some types a '&' sign as the first charater of the array.
So if some types: &this is text. It will end or if someone just types: &
It will end, Understand?


Thanks for any help

Matt





#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream.h>

#define YES 1
#define NO 0 // not used

struct data {
char* text;
int bold, italic, underline;
};

void createPage ( struct data *array, int num );

int main ( void ) {
int response, i;
char buff[BUFSIZ];
struct data myStructArray[80];

// this loop in a function would be a good idea
for ( i = 0 ; i < 80 ; i++ ) {
printf( "Please enter a line of text (blank to exit): " );
fflush( stdout );
fgets( buff, BUFSIZ, stdin );
if ( strlen(buff) == 1 ) break;
// y = buff;
// strcmp(x, y);
// puts(buff);
// printf("%d", strcmp(x, y));

myStructArray[i].text = malloc( strlen(buff)+1 ); // allocate space
strcpy( myStructArray[i].text, buff );

printf( "\nDo you want text to be bold?[1/0] " );
fflush( stdout );
fgets( buff, BUFSIZ, stdin );
sscanf( buff, "%d", &response );
myStructArray[i].bold = response;

printf( "\nDo you want text to be Italics?[1/0] " );
fflush( stdout );
fgets( buff, BUFSIZ, stdin );
sscanf( buff, "%d", &response );
myStructArray[i].italic = response;

printf( "\nDo you want text to be Underlined?[1/0] " );
fflush( stdout );
fgets( buff, BUFSIZ, stdin );
sscanf( buff, "%d", &response );
myStructArray[i].underline = response;
}

createPage( myStructArray, i );
return 0;
}

void createPage( struct data *a, int num ) {
int i;
FILE* outFile;
outFile = fopen( "phaseTwo.html","w" );

/* All HTML files must start with this tag. */
fprintf( outFile,"<html>\n" );

for ( i = 0 ; i < num ; i++, a++ ) {
if(a->bold == YES) {
fprintf( outFile,"<b>" );
}
if(a->italic == YES) {
fprintf( outFile,"<i>" );
}
if(a->underline == YES) {
fprintf( outFile,"<u>" );
}

/* Write to the file HTML representing a line of text. */
fprintf( outFile,"<p>" );
fprintf( outFile,"%s",a->text );
fprintf( outFile,"</p>\n" );

if(a->bold == YES) {
fprintf( outFile,"</b>\n" );
}
if(a->italic == YES) {
fprintf( outFile,"</i>\n" );
}
if(a->underline == YES) {
fprintf( outFile,"</u>\n" );
}
}

fprintf( outFile,"</html>\n" );
fclose( outFile );
}