I want to read a int from stdin but I want to validate if the user exceeds the int max value. How can I do it?
int n;
scanf("%d", &n);
scanf reads the decimal input and stores in the int, causing overflow. How can I check and avoid this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…