-
Program Control Help
Hello Board,
I am having trouble with basic program control. I finally seem to understand structures, pointers and passing to functions. However, I need help with some program control. This program passes structure pointers to a function which then outputs to an HTML file. However the user needs to provide some text which is then passed as Text to website. The user then is prompted to change to Italics, Bold etc which is passed to function and manipulated there. I just can't comprehend how to setup menu. 1 for accepting the change 0 to not accept the change. Here is what I Have thus far (edited):
int in_response;
fflush(stdin);
printf("Please type some text for your web page and press enter");
scanf("%c",&txtinput.txt);
fflush(stdin);
while (1)
{
printf("Enter 0 if you do not want bold text.\n");
printf("Enter 1 to if you do want bold text.\n");
printf(">-->> ");
scanf("%d",&in_response);
/* if user inputs 1 continue to utility if the
user enters 0 exit the program */
if (in_response == 1) &txtinput.bold;
if (in_response == 0) exit(0);
}
fflush(stdin);
while (1)
{
printf("Enter 0 if you do not want italics text.\n");
printf("Enter 1 to if you do want italics text.\n");
printf(">-->> ");
scanf("%d",&in_response);
/* if user inputs 1 continue to utility if the
user enters 0 exit the program */
if (in_response == 1) &txtinput.italics;
if (in_response == 0) exit(0);
}
-
> fflush(stdin);
This is undefined and depending on your compiler, won't work, or will work incorrectly.
> if (in_response == 1) &txtinput.bold;
What is this supposed to do? Is this a function pointer? Either way, why are you trying to produce it's address? The '&' symbol does one of two things:
1) applies a bitwise AND
2) produces the address of the variable it's used with
In either case, your if section here does nothing benificial, or correct for that matter.
Quzah.
-
I need to rethink this one again. Apparently I am way off base at this point.