Anyone know of a comprehensive site, that talks about the:
while (scanf("%d", &var) == 1)
{
while (getchar() != 'n');
printf("Try again: ");
}
As i'm trying to figure out why, it's compared to 1 (i get it one variable is being pointed to and written too. So 1, and if there was &var, var) it'd be == 2), naturally the var without the &ersand means the var is a char, or a string variable, and does not need one.)
However scanf("%d", &var); has serious issues with taking a string it will crash the program they called it some End of line error or something. As it's set to read integers, and so if a string is intered it will go nuts.
Anyways i'm looking for a comprehensive site that will explain in detail the comparison of scanf(""); and some detail as to better data validation as although the above method will work and block a string from being entered till a number is entered, if you enter a # then a string after it. "# char" the program will also crash again, and thus the above fix is void, however if it's just a number (as it's suppose to be, then it works fine and goes through the rest of the program code to compare the number with the conditionals set for it, and it's limits.)
Anyways if anyone happens to know, of any good sites that aren't too full of ego and bullshit.
Let me know.
if not, no worries. I just get angry when something makes nosense to me yet i can still use it (to make things work) but not knowing why it's working the way it does, is very annoying.
Everything in the program works fine, and no it's not a program / project for school it's just practice.
Reading what degree to determine the angle limiting the degrees so they can't go below 0 or over 360 degrees.
That sort've thing. It's done and built but i'm trying to figure out better data validation. As i feel, it'd be great to be capable to build programs 100% error free at least syntax wise, not that they won't be incompatible with other systems and stuffs.
Most should work on any system provided you follow the C99 standards.
Anyways let me know.
Thanks.
while (scanf("%d", &var) == 1)
{
while (getchar() != 'n');
printf("Try again: ");
}
As i'm trying to figure out why, it's compared to 1 (i get it one variable is being pointed to and written too. So 1, and if there was &var, var) it'd be == 2), naturally the var without the &ersand means the var is a char, or a string variable, and does not need one.)
However scanf("%d", &var); has serious issues with taking a string it will crash the program they called it some End of line error or something. As it's set to read integers, and so if a string is intered it will go nuts.
Anyways i'm looking for a comprehensive site that will explain in detail the comparison of scanf(""); and some detail as to better data validation as although the above method will work and block a string from being entered till a number is entered, if you enter a # then a string after it. "# char" the program will also crash again, and thus the above fix is void, however if it's just a number (as it's suppose to be, then it works fine and goes through the rest of the program code to compare the number with the conditionals set for it, and it's limits.)
Anyways if anyone happens to know, of any good sites that aren't too full of ego and bullshit.
Let me know.
if not, no worries. I just get angry when something makes nosense to me yet i can still use it (to make things work) but not knowing why it's working the way it does, is very annoying.
Everything in the program works fine, and no it's not a program / project for school it's just practice.
Reading what degree to determine the angle limiting the degrees so they can't go below 0 or over 360 degrees.
That sort've thing. It's done and built but i'm trying to figure out better data validation. As i feel, it'd be great to be capable to build programs 100% error free at least syntax wise, not that they won't be incompatible with other systems and stuffs.
Most should work on any system provided you follow the C99 standards.
Anyways let me know.
Thanks.
Comment