Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

OK can someone tell my why I keep getting error C2664 when I try to build my c++ code?

Its starting to tick me off here's the code.

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

int main()

{

FILE *suture;

float batchnumber, temp, pressure, dwelltime;

/* Execute instructions to solve the problem. */

suture=fopen("suture.dat","r");

if ((suture=fopen(suture,"r"))==NULL)

{printf("Could not open %s.\n", suture); return EXIT_FAILURE;}

while (fscanf(suture,"%lf %lf %lf %lf", &batchnumber, &temp, &pressure, &dwelltime)==4)

printf("Batch %lf \nTemperature (C) %lf \nPressure(psi)\n Dwell Time %lf\n",

batchnumber, temp, pressure, dwelltime);

return EXIT_SUCCESS;

}

I have a data file named suture.dat that I'm trying to read from and simply have the data from that file display on the screen.

Please Help!!!

1 Answer

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    Hello,

    The error C2664 involves an incorrect argument type for your second fopen call.

    Your code of:

    if ((suture=fopen(suture,"r"))==NULL)

    {printf("Could not open %s.\n", suture); return EXIT_FAILURE;}

    Should be this instead:

    if (suture==NULL)

    {printf("Could not open suture.dat\n"); return EXIT_FAILURE;}

    Please note that I also changed the printf statement in addition to the contents of the if statement. You were trying to pass a FILE* as a string.

    Hope this helps.

Still have questions? Get your answers by asking now.