我尝试在以下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 Successfuln");
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程序。当我尝试在终端上制作makefile时,我会在" {'oken"之前遇到"预期")。谁能告诉我代码中的问题在哪里?
谢谢
if ( ( outfile = open(test2,O_WRONLY|O_CREAT|O_TRUNC,PERM ) == -1)
^ 2 1 1 2
您可以看到此括号是无与伦比的。