Apologies first up. I've been at this one part of code for about 4 hours now I've gotten so frustrated with myself.
I had a working while loop with scanf but wasn't happy with not being able to handle special characters and causing an endless loop if the user entered anything other than a numeric number.
I've attempted to switch to fgets and fputs to handle that as most replies to similar questions suggest but I'm clearly lacking the foundation of how these work. Even with some similar examples.
Issue is I can't get out of the while statement despite entering a value between 1-9. I'm guessing it's because I've failed somewhere within the char to int switch.
If I simplify the if statement to one variable it skips the loop entirely. It's quite odd.
Appreciate any advice.
fputs("Please enter robot starting position [0-9]:", stdout);
fgets(start_position, sizeof(start_position), stdin);
input = (int)strtol(start_position, NULL, 10);
while ((start_position <= 0) || (start_position >= 10)) {
fputs("Starting position must be between 0-9 (inclusive).\n\n", stdout);
fputs("Please enter starting position [0-9]:", stdout);
fgets(start_position, sizeof(start_position), stdin);
input = (int)strtol(start_position, NULL, 10);
}