Please use code blocks when posting code.

The problem, as always, is scanf. This is a REALLY SHIT way of getting user input. I honestly cannot fathom why teachers insist on teaching it.

Change op to a character array and use fgets. Then
Code:
if (op[0]=='i')
{
  printf("OH DEAR etc");
  return;
}
By the way you don't need so many returns. You don't need any, in fact. Or the else clause:
Code:
if (op[0]=='i')
{
  // display instructions
}
} // end of function close bracket.
If you're still wondering why it doesn't work as you originally wrote it, here's the tech explanation. scanf scans user input converting what it finds and placing it in the specified variables. Now unfortunately, you can't just enter a single character; you have to press RETURN before the input is processed. So the input stream if you enter i<RETURN> comprises the letter i and the return character. scanf finds the i, matches that with the single character spec %c and puts that into op. It leaves the rest of the input buffer untouched. So when your fgets function starts, it finds the RETURN character that scanf "helpfully" left on the input stream and takes that as the user input.

The best solution to this is to drop scanf ALTOGETHER and NEVER use it at all. Use fgets to read a string from the user, then you can always use sscanf if you want - that is fine, because there will be no confusion. sscanf is like scanf but reads from a string instead of from stdin. In this case though no sscanf is needed - you only want to see if the first character entered was an i so that you can display the instructions.

There is a way to get scanf to process the RETURN - the easiest is just to do something like
Code:
char op;
char dummy;
scanf("%c%c",op,dummy);
which is fine until the stupid user enters "no, sod off<ENTER>", at which point scanf will set op to 'n', dummy to 'o', and leave ", sod off<ENTER>" for fgets. You could scanf in a loop until you hit ENTER, but at that point it really becomes a lot simpler just to do
Code:
char op[32];
fgets(op,32,stdin);
if (op[0]=='i')...

Last edited by xpi0t0s; 8Jul2011 at 10:44..