I don't suppose you've read the manual page for scanf in all your fumbling around.
man page scanf section 3
So, begin withRETURN VALUES
These functions return the number of input items assigned. This can be
fewer than provided for, or even zero, in the event of a matching fail-
ure. Zero indicates that, although there was input available, no conver-
sions were assigned; typically this is due to an invalid input character,
such as an alphabetic character for a `%d' conversion. The value EOF is
returned if an input failure occurs before any conversion such as an end-
of-file occurs. If an error or end-of-file occurs after conversion has
begun, the number of conversions which were successfully completed is
returned.
int result = scanf("%d",&matrix[c][d]);
printf("scanf returned %d\n", result );
And observe what you get when you
- type in a number
- type in a letter
- type in your platform specific key sequence (ctrl-d or ctrl-z) to signal EOF



4Likes
LinkBack URL
About LinkBacks


