When opening the c++ file, an error occurred in the line number below.
There were 12 errors, but I couldn't solve them.
I would appreciate it if you could give me your knowledge.
/****************/
/* Main Routine*/
/* ****************** */
void main (void)
{
FILE*fi,*fo;
int sou, i, j, mode;
float dat;
long learn;
while(1){
mode = mode_sel();
if(mode==3)break;
printf("\x1b*");
sou = junbi(mode);
if(mode==1)
printf("\nPlease enter a data filename:");
if(mode==2)
printf("\nPlease enter a filename:");
72fi = openfile("rt", AGAIN);
fscanf(fi, "%d", & account);
for(i=0;i<icount;i++){
for(j=0;j<node[0];j++){
fscanf(fi, "%f", & dat);
ind [node[0]*i+j] = dat;
}
}
fclose(fi);
if(mode!=2){
printf("Please enter a data file name:");
84 fo = openfile("rt", AGAIN);
voidomomi(intsou)
{
FILE*wfi;
challenge [20];
inti,j,n;
printf("Do you want to use existing data? (y/n):");
if(hityn()==YES){
printf("File Name:");
147 wfi = openfile("rt", AGAIN);
void neu_cal(int saw, long learn)
{
FILE*fe;
intyn, wmode, i, j, next;
float averr, outerr [20];
long kai;
kai = 1L;
wmode=w_ren_mode();
printf("\nDo you want to print the error to the file? (y/n):");
if((yn=hityn())==YES){
printf("Please enter the output error filename:");
181fe=openfile("wt", AGAIN);
void wf_write(intsou)
{
FILE*wfo;
inti,j,n;
printf("\nPlease enter the output filename:");
413 wfo = openfile("wt", AGAIN);
/* ******************** */
/* Open File*/
/* ******************** */
FILE* openfile(int*mode, intsw)
{
charfn [25];
FILE*fp;
while(1){
scanf("%s",fn);
487 if((fp=fopen(fn,mode)))==NULL){
printf("%s could not be opened.\n", fn);
if(sw==EXIT)exit(1);
printf("Please re-enter the file name:");
} else {
break;
}
}
return(fp);
}
[Error indication] 12 Errors
Error (active) E0304 An instance of overloaded function "openfile" does not match the argument list*.CPP72
Error (active) E0304 Instance of overloaded function "openfile" does not match argument list*.CPP84
Error (active) E0304 Instance of overloaded function "openfile" does not match argument list*.CPP147
Error (active) E0304 Instance of overloaded function "openfile" does not match argument list*.CPP181
Error (active) E0304 Instance of overloaded function "openfile" does not match argument list*.CPP413
Error (active) Argument for type E0167 "int*" is incompatible with parameter of type "const char*".CPP487
Error C2664 'FILE* openfile(char*, int)': Cannot convert argument 1 from 'const char[3]' to 'char*'. *.CPP72
Error C2664 'FILE* openfile(char*, int)': Cannot convert argument 1 from 'const char[3]' to 'char*'. *.CPP84
Error C2664 'FILE* openfile(char*, int)': Cannot convert argument 1 from 'const char[3]' to 'char*'. *.CPP147
Error C2664 'FILE* openfile(char*, int)': Cannot convert argument 1 from 'const char[3]' to 'char*'. *.CPP181
Error C2664 'FILE* openfile(char*, int)': Cannot convert argument 1 from 'const char[3]' to 'char*'. *.CPP413
Error C2664 'FILE*fopen(const char*, const char*)': Cannot convert argument 2 from 'int*' to 'const char*'. *.CPP487
In response to Sayuri's suggestion, I compiled the source saved with UTF (with BOM) with the extension C, and it worked.
said he.Let me explain this.
The Visual C++ Compiler can handle both C and C++ languages.If the source code extension is .c
, compile it as C language, and if .cpp
, compile it as C++ language.Alternatively, you can specify a language such as compilation options/TC/TP.
Here, C and C++ languages are similar but also different.Error Message
An instance of overloaded function "openfile" does not match the argument list
However, the concept of "overload" does not exist in the C language, only in the C++ language.Therefore, this is an error that occurs when the source code of C language is compiled as C++ language, and the error that would not occur if the source code of C language was compiled as C language.
Also, the code was in C language, but I compiled it in VS2019, and cpp was selected, so I chose cpp's question.
It is the responsibility of the questioner to understand the language you want to use ( 利用 the language you are using).For example, it is nonsense to ask questions without knowing whether you are speaking Japanese or English.
If you are dealing with C source code, the language you would definitely like to use is C.
The argument for the function called openfile is inconsistent with the declaration
Let's do something about this
© 2024 OneMinuteCode. All rights reserved.