Edit: After prompting the user to choose between “login (1)” and “create an account (2)”, I am trying to have the program check that:
- the input is an integer
- that the input, in case of an integer, is only valid if one (1) or two (2)
- (optionally) that the data size of the user input is not greater than the integer number one (1) or two (2), as a security measure, to hinder overflow exploits
If I allocate [] or [] to intCheck the program goes into an endless loop from the very start. No user input required. If, however, I allocate [] or more, the program works as intended, as long as the total size of bytes of the user input is less than the number of bytes previously allocated. If, however, the user input results in a byte size greater than what was preallocated, the program repeats the else condition of the while loop - here, printf - that number of times. Is this an overflow of choice or what?
//Bank of Haruhi
//TODO
// - Create user account: require user first name, last name, user name, password, age (deny if < 20 yrs)
// - Prompt login (deny if != password && username)
// - Display menu ("About the Bank of Haru", "Account Settings", "Check your balance", "Deposit", "Withdraw", "Close account", "Logout")
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
int main(void) {
//Base
char intCheck[3] = ""; //Will "if (sscanf(char,%d,&int) == true)" check for ANY "char" or a predetermined amount of "char"?
//Registration and login
char firstName[] = "";
char lastName[] = "";
char password[] = "";
int age = 0;
//Menues and selections
int choice = 0;
int arithmeticChoice = 0;
//Balance, deposit and withdrawal
float balance = 0.0;
float deposit = 0.0;
float withdraw = 0.0;
printf("Welcome to the Bank of Haruhi! Please login (1) or create an account (2): ");
while (fgets(intCheck, sizeof(intCheck),stdin)) {
intCheck[strlen(intCheck) - 1] = '\0';
if (sscanf(intCheck, "%d", &choice) == true && sizeof(intCheck) == 4 && choice == 1 || choice == 2) break; //I'm keeping "sizeof(intCheck)" in order to excercise byte size input validation, but I could just remove it and let "if choice == 1 || 2" restrict the valid input.
else printf("Please enter ""1"" to login or ""2"" to create a new account: ");
}
return 0;
}
The program is, of course, not nearly complete. I just stopped doing anything else, as soon as I stumbled upon this phenomenon.


Some very reasonable points, but I do not support what you say about C itself.
A bunch of languages work this way, and then you can understand them better if you have learned C before.
But other languages simply don’t work this way.
This is not specific about C, it is just coincidentally that the creators of newer languages had learned their C before, and then rebuilt some of the basic concepts into their new languages.
But then you should actually skip Java and go directly to Kotlin.
C already has the basics of these concepts, that have been developed further a little later, while C was developed into C++ (which I don’t recommend anymore today).