Greetings, working on some basic code here.
Usually I run the following code to test input as non-integers or negatives, as most of my programs use positive integers.
However, I can't seem to apply that same principle to multiple inputs at once...Code:while (scanf("%f", &input) != 1 ? scanf("%s") : 0 || input< 0) { printf("Error! "); printf("Please enter input: "); }
Does anyone know a good way to solve this problem?Code:printf("Enter a date (mm/dd/yy): "); while (scanf("%d/%d/%d", &m2, &d2, &y2) != 1 ? scanf("%s") : m2 < 0 || d2 < 0 || y2 < 0) { printf("Error! "); printf("Enter a date (mm/dd/yy): "); }
The entire point of this program is to determine the earliest date out of however many dates the user inputs.
Full code here: [C] c06p10.c - Pastebin.com