From: GNR100@psuvm.psu.edu
Newsgroups: comp.lang.c
Subject: Floating Point Formats Not Linked
Date: 15 Sep 92 22:15:08 GMT
Organization: Penn State University


  Hi.  I'm having a problem with double-precision numbers.I can't get scanf()
to read them in.  I know about using %lf, I know about the '&', and I checked
the declaration statements.The compiler doesn't complain, but the program
crashes as soon as it gets to 'scanf("%lf", &matrix[ROW] [COL]);'
I am only posing a portion of the copde to save space, but if you would like
to see the rest, let me know and I will gladly send it out.

              all help appreciated,
                  Gordon Rogers
                  gnr100@psuvm.psu.edu
/*----------------------BEGIN CODE ---------------------------------*/
#include <stdio.h>
#define MAX 5


/*
   define macros for use in array subscrpits, to simplify using cell
   zero as row or column one.
*/

#define ROW  (row-1)
#define COL  (col-1)
#define PASS (pass-1)


/*
  set up macros to declare matrices, making the size
  both more clear and easier to modify
*/

#define AROWLIM MAX
#define ACOLLIM (2*MAX)
#define CROWLIM MAX
#define CCOLLIM 1
#define BROWLIM AROWLIM
#define BCOLLIM CCOLLIM


/*
   declare global variables for use in
   proccessing arrays in functions
*/

int Arowmax;
int Acolmax;  /* A will have 2x the needed columns to enable inversion */
int Acolsum;  /* A will usually be processed as just the first half    */
              /* Acolmax is the size of each half, Acolsum is the      */
              /* actual number of columns.  This was done to simplify  */
              /* parameters.                                           */

int Crowmax;
int Ccolmax;
int Bcolmax;
int Browmax;
int size;

/* Function Prototypes */
get_coefficient_matrix(double matrix[AROWLIM] [ACOLLIM]);
                 double B[BROWLIM] [BCOLLIM],
                 double C[CROWLIM] [CCOLLIM] );

main()
{
 double A[AROWLIM] [ACOLLIM];
 double B[BROWLIM] [BCOLLIM];
 double C[CROWLIM] [CCOLLIM];

 /*
   finish seting up global variables
   to define matrices in parameters
 */

 Ccolmax=CCOLLIM;
 Bcolmax=Ccolmax;


 get_coefficient_matrix(A);
}

/*-------------------------get_coeficient_matrix()-----------------------*/
 /*************************************************************************
 ** The purpose of this function is to  input the coeficient matrix.     **
 ** It assumes a complex matrix.                                         **
 *************************************************************************/
get_coefficient_matrix(double matrix[AROWLIM] [ACOLLIM])
{
 int row, col;


 clrscr();
 printf("\nInput the Coefficient Matrix (It must be a square matrix)");
 printf("\n\n\tInput the size of the matrix (enter one integer).");
 printf("\n\t\t(maximum of %d )\n\n\t\t\t", MAX);
 scanf("%d", &size);

 /* define global variables for use in functions */
 Arowmax=size;
 Acolmax=Arowmax;
 Crowmax=size;
 Browmax=Arowmax;

 /* input coeficient matrix */
 for (row=1; row<=size; row++)
   {
    for (col=1;col<=size; col++)
       {
        printf("\nInput element %d , %d \n", row, col);
        scanf("%lf", &matrix[ROW] [COL]);
       } /* end col loop */
   }     /* end row loop */
 }       /* end get_coeficient_matrix() */
Newsgroups: comp.lang.c