13-2.txt
来自「c primer 部分习题答案」· 文本 代码 · 共 45 行
TXT
45 行
PE 13-2
/* Programming Exercise 13-2 */
#include <stdio.h>
#include <stdlib.h>
//#include <console.h> /* Macintosh adjustment */
int main(int argc, char *argv[])
{
int byte;
FILE * source;
FILE * target;
// argc = ccommand(&argv); /* Macintosh adjustment */
if (argc != 3)
{
printf("Usage: %s sourcefile targetfile\n", argv[0]);
exit(EXIT_FAILURE);
}
if ((source = fopen(argv[1], "rb")) == NULL)
{
printf("Could not open file %s for input\n", argv[1]);
exit(EXIT_FAILURE);
}
if ((target = fopen(argv[2], "wb")) == NULL)
{
printf("Could not open file %s for output\n", argv[2]);
exit(EXIT_FAILURE);
}
while ((byte = getc(source)) != EOF)
{
putc(byte, target);
}
if (fclose(source) != 0)
printf("Could not close file %s\n", argv[1]);
if (fclose(target) != 0)
printf("Could not close file %s\n", argv[2]);
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?