Q1: Is tmp assigned to the values of the number and operator from buf? Q2: Why does my program exit, if I input "3+"? Q3: Where do you check for the extra spacing?
Q1: Is tmp assigned to the values of the number and operator from buf? A1: NO, "tmp" is only assigned the number. Remember to put a '\0' at the end of your tmp[] before atof() "op" is assigned the operator.
Q2: Why does my program exit, if I input "3+"? A2: The input will always have a space between the operand and operator.
Q3: Where do you check for the extra spacing? A3: 1) Look at the sample input. Two places have extra spacing. a) Before the number b) Before the operator Therefore place the given while loop skipping spaces in those 2 locations. 2) NOTE: Do **NOT** check for a specific 'A' or 'B'!!! The "isdigit()" should be doing this. Do not "hardcode" an 'A' into your source code. 3) Therefore the BIG picture. "[]" optional Legal Input: whitespace Real_number whitespace Operator Legal Operator: + - * / = q Q Legal Real_number: [minus] number [.] [number] or [minus] [number] . [number]