The performance of scanf()
of int
and long
is certainly of insignificant difference. But OP asks another, more interesting question
My doubt is in which of them the data will get stored first ????
C does specify "The fscanf function executes each directive of the format in turn." which strongly suggest i
is written before j
, etc. I take that to mean the processing of text input happens in the order of of the format, but is just short of specifying the order in which i,j,k
are written.
I have my doubts about the following and have posted a question.
To be clear, if i,j,k
are all scanned, the library may write k
first.
How is code to tell and why should it care? The order in which the incoming text and how it is applied to i,j,k
is specified. Of course, if only 1 or 2 of the 3 are scanned. k
is not written.
Best to check the return value as that informs the calling code the success of the call.
switch (scanf("%lld %ld %d",&i,&j,&k)) {
case 3: puts("Success"); break;
case 2: puts("Only i,j"); break;
case 1: puts("Only i"); break;
case 0: puts("None"); break;
case EOF: puts("EOF or input error"); break;
}