[英]Makefile error on C program “expected ‘)’ before ‘{’ token”
I get an error when I try to make the Makefile on the following C program. 尝试在以下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(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 */
}
This is my C program. 这是我的C程序。 I get the error "expected ')' before '{' token" when I try to make the Makefile on terminal.
尝试在终端上制作Makefile时,出现“ {'令牌”之前的错误“ expected')”。 Can anyone tell me where the problem in my code is?
谁能告诉我代码中的问题在哪里?
Thank you 谢谢
if ( ( outfile = open(test2,O_WRONLY|O_CREAT|O_TRUNC,PERM ) == -1)
^ 2 1 1 2
As you can see this parenthesis is unmatched. 如您所见,该括号是不匹配的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.