|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
最近在图书馆借了本书,上面的第一个例题就把我给难住了,没办法,只好有请各位大仙下凡,帮忙解决下吧!
例子的代码是这个!
/* Chapter 1. Basic cp file copy program. C library Implementation. */
/* cpC file1 file2: Copy file1 to file2. */
#include <stdio.h>
#include <errno.h>
#define BUF_SIZE 256
int main (int argc, char *argv [])
{
FILE *inFile, *outFile;
char rec[BUF_SIZE];
size_t bytesIn, bytesOut;
if (argc != 3) {
fprintf (stderr, "Usage: cp file1 file2\n");
return 1;
}
inFile = fopen (argv[1], "rb");
if (inFile == NULL) {
perror (argv[1]);
return 2;
}
outFile = fopen (argv[2], "wb");
if (outFile == NULL) {
perror (argv[2]);
fclose(inFile);
return 3;
}
/* Process the input file a record at a time. */
while ((bytesIn = fread (rec, 1, BUF_SIZE, inFile)) > 0) {
bytesOut = fwrite (rec, 1, bytesIn, outFile);
if (bytesOut != bytesIn) {
perror ("Fatal write error.");
fclose(inFile); fclose(outFile);
return 4;
}
}
fclose (inFile);
fclose (outFile);
return 0;
}
这个程序用c语言的编译器是可以运行的,可是运行后无法给‘main’函数传参。所以总是出错。
请大牛帮帮忙,教教我怎么给他传参。最好加个截图啥的。要是无法添加截图,麻烦加我qq1065933657给我发一个截图吧!
跪拜中!!!!!
|
|