At least three changes are needed:
You need to change the first
"%d"
infscanf
to"%lf"
because&R[n][m]
is a pointer to adouble
.And change the second
"%d"
infprintf
to"%f"
.And move
double R[128][256];
so that both sections use the same array (and delete the second definition).
Or, declare R
to be int
rather than double
.
Edit: What compiler are you using? Most widely-used compilers should have given you a warning. For example, gcc
gives, with standard switches, the warnings:
Line 1: warning: extra tokens at end of #include directive
Line 18: warning: format '%d' expects type 'int *', but argument 3 has type 'double *'
Line 32: warning: format '%d' expects type 'int', but argument 3 has type 'double'
(plus a complaint about the prototype of main()
).