My question is, why when we use a function fgets() in that kind of way
there is no else statemant?Code:if(fgets (buf, sizeof buf, stdin) != NULL) { //stuff }
just curious
My question is, why when we use a function fgets() in that kind of way
there is no else statemant?Code:if(fgets (buf, sizeof buf, stdin) != NULL) { //stuff }
just curious
What are you talking about? If you want an else write one.
Quzah.
Hope is the first step on the road to disappointment.
The stuff is executed only if fgets() gets a non-null value from the standard input.
If you want some error to be printed in case a null string was input try this :
Code:if(fgets(mychar, sizeof(mychar), stdin) { //stuff } else { //print error }