: error C2664: 'fopen' : cannot convert parameter 1 from 'int [10]' to 'const char *'
#include<stdio.h>#include<stdlib.h>voidmain(){FILE*from,*to;//定义文件指针charch;intin[10],...
#include <stdio.h>
#include <stdlib.h>
void main()
{
FILE *from ,*to;//定义文件指针
char ch;
int in[10],out[10];
printf ("please enter in flie name \n");
scanf ("%s",in);
printf ("please enter out flie name \n");
scanf ("%s",out);
if ((from= fopen (in,"r"))==NULL)//以只读的方式打开被复制文件, 这里出现错误??
{
printf ("cannont open file \n");
exit(0);
}
if ((to =fopen (out ,"w" ))==NULL)//这里出现错误??
{
printf ("cannont open file \n");
exit(0);
}
while (!feof (from))
fputc (fgetc (from),to);//将文件内容复制,直到文件结束
fclose (from);//关闭文件
fclose (to); //关闭文件
}
编译错误 :
\17-4.cpp(12) : error C2664: 'fopen' : cannot convert parameter 1 from 'int [10]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\17-4.cpp(17) : error C2664: 'fopen' : cannot convert parameter 1 from 'int [10]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
求高手 帮忙 看一下 ,怎么修改 ,谢谢谢谢谢!! 展开
#include <stdlib.h>
void main()
{
FILE *from ,*to;//定义文件指针
char ch;
int in[10],out[10];
printf ("please enter in flie name \n");
scanf ("%s",in);
printf ("please enter out flie name \n");
scanf ("%s",out);
if ((from= fopen (in,"r"))==NULL)//以只读的方式打开被复制文件, 这里出现错误??
{
printf ("cannont open file \n");
exit(0);
}
if ((to =fopen (out ,"w" ))==NULL)//这里出现错误??
{
printf ("cannont open file \n");
exit(0);
}
while (!feof (from))
fputc (fgetc (from),to);//将文件内容复制,直到文件结束
fclose (from);//关闭文件
fclose (to); //关闭文件
}
编译错误 :
\17-4.cpp(12) : error C2664: 'fopen' : cannot convert parameter 1 from 'int [10]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\17-4.cpp(17) : error C2664: 'fopen' : cannot convert parameter 1 from 'int [10]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
求高手 帮忙 看一下 ,怎么修改 ,谢谢谢谢谢!! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询