C程序上的Makefile错误;预期的‘;)’;在‘之前;{&x2019;代币“;
当我试图在下面的C程序上生成Makefile时,我遇到了一个错误C程序上的Makefile错误;预期的‘;)’;在‘之前;{&x2019;代币“;,c,C,当我试图在下面的C程序上生成Makefile时,我遇到了一个错误 int main() { char filename_src[101], filename_dest[101]; printf("\nSource file: "); gets_s(filename_src, 100); printf("\nDestination filename: "); gets_s(filename_dest, 100); if(copy_file(f
int main()
{
char filename_src[101], filename_dest[101];
printf("\nSource file: ");
gets_s(filename_src, 100);
printf("\nDestination filename: ");
gets_s(filename_dest, 100);
if(copy_file(filename_src, filename_dest) == 0)
printf("Copy Successful\n");
else
fprintf(stderr, "Error during copy!");
copyfile( filename_src, filename_dest );
}
int copyfile( const char *test1, const char *test2 )
{
int infile, outfile;
ssize_t nread;
char buffer[BUFSIZE];
if( ( infile = open(test1, O_RDONLY) ) == -1 )
return (-1);
if( ( outfile = open(test2,O_WRONLY|O_CREAT|O_TRUNC,PERM ) == -1)
{
close(infile);
return (-2);
}
/* now read from test1 BUFSIZE chars at a time*/
while( (nread = read(infile, buffer, BUFSIZE) ) > 0)
{
/*write buffer to output file*/
if( write(outfile, buffer, nread) < nread )
{
close(infile);
close(outfile);
return (-3); /*write error*/
}
}
close(infile);
close(outfile);
if( nread == -1 )
return (-4); /*error on last read*/
else
return (0); /*all is well */
}
intmain()
{
char filename_src[101],filename_dest[101];
printf(“\n源文件:”);
获取\u s(文件名\u src,100);
printf(“\n目标文件名:”);
获取\u s(文件名\u dest,100);
if(复制文件(filename\u src,filename\u dest)==0)
printf(“复制成功\n”);
其他的
fprintf(stderr,“复制时出错!”);
copyfile(文件名\u src,文件名\u dest);
}
int copyfile(常量字符*test1,常量字符*test2)
{
内填充,外填充;
ssize_t nread;
字符缓冲区[BUFSIZE];
如果((infle=open(test1,orduonly))=-1)
返回(-1);
if((outfile=open(test2,O_WRONLY | O_create | O_TRUNC,PERM)=-1)
{
关闭(填充);
回报率(-2);
}
/*现在一次读取test1 BUFSIZE字符*/
而((nread=read(infle、buffer、BUFSIZE))>0)
{
/*将缓冲区写入输出文件*/
if(写入(输出文件、缓冲区、nread)
这是我的C程序。当我试图在终端上生成Makefile时,在“{”token”之前出现了错误“expected”)。有人能告诉我代码中的问题在哪里吗
多谢各位
if ( ( outfile = open(test2,O_WRONLY|O_CREAT|O_TRUNC,PERM ) == -1)
^ 2 1 1 2
正如您所见,此括号不匹配。错误消息将包括行号。如果您不知道如何在错误消息中找到行号,请在问题中包含完整的错误消息。