Home c FPRINTF function in SI

FPRINTF function in SI

Author

Date

Category

wrote a program of working with matrices and vectors. All calculations spent higher, it remains only to display the results to the file. The matrix is ​​announced as a double. Here is a fragment of code:

file * inputfile;
  INPUTFILE = FOPEN ("INPUT.TXT", "W +");
FPRINF (INPUTFILE, "Matrix C \ R \ N \ R \ n");
For (int i = 0; i & lt; m; i ++) {
  For (int j = 0; j & lt; n; j ++) {
    FPRINTF (INPUTFILE, "%. 2LF", C [I] [J]);
    FPRINF (INPUTFILE, "\ T \ T");
  }
  FPRINTF (INPUTFILE, "\ R \ N \ r \ n");
}
FClose (Inputfile);

When compiling issues errors. F: \ Mingw \ include \ stdio.h: 453: 38: Note: Expected ‘Const Char *’ But Argument Is of Type ‘Double’. other.


Answer 1

Try Add (char *) in front of the pointer to the matrix, which is transmitted to the FPRINTF function.

fprintf (inputfile, "%. 2lf", (char *) C [i] [J]);

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions