Why does the code use
input_is_good = (scanf("%ld",&num) == 1);
instead of
input_is_good = scanf("%ld",&num);
Both of them are success, are there any difference between them?
#include <stdio.h>
#include <stdbool.h>
int main(int argc, const char * argv[]) {
long num;
long sum =0L;
bool input_is_good;
printf("please enter an integer to be summed");
printf("(q to quit):");
input_is_good = (scanf("%ld",&num) == 1);
while (input_is_good) {
sum+= num;
printf("please enter next integer (q to quit):");
input_is_good = (scanf("%ld",&num) == 1);
}
printf("sum to %ld\n",sum);
return 0;
}
What is the distinction between the former and the latter?