当我尝试在以下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 */
}
这是我的C程序。我在“{'令牌&#34;之前得到错误&#34;期望')'当我尝试在终端上制作Makefile时。谁能告诉我代码中的问题在哪里?
谢谢
答案 0 :(得分:2)
if ( ( outfile = open(test2,O_WRONLY|O_CREAT|O_TRUNC,PERM ) == -1)
^ 2 1 1 2
正如您所看到的,这个括号是无与伦比的。