#include <stdio.h>
#include <stdlib.h> //为了调用exit()
#include <string.h> //为strcpy()和strcat()函数提供原型
#define LEN 40
int main(int argc, char *argv[])
{
FILE *in, *out; //声明两个FILE指针
int ch;
char name[LEN]; //用于存储输入文件名
int count = 0;
//检查命令行参数
if(argc < 2)
{
fprintf(stderr, "Usage: %s filename.\n", argv[0]);
exit(1);
}
//实现输入
if((in = fopen(argv[1], "r")) ==
#include <stdlib.h> //为了调用exit()
#include <string.h> //为strcpy()和strcat()函数提供原型
#define LEN 40
int main(int argc, char *argv[])
{
FILE *in, *out; //声明两个FILE指针
int ch;
char name[LEN]; //用于存储输入文件名
int count = 0;
//检查命令行参数
if(argc < 2)
{
fprintf(stderr, "Usage: %s filename.\n", argv[0]);
exit(1);
}
//实现输入
if((in = fopen(argv[1], "r")) ==

这个C语言程序接收命令行参数作为输入文件名,然后创建一个带有'.red'后缀的新文件,将输入文件的内容复制到新文件中。程序首先检查命令行参数,然后打开输入和输出文件,并通过getc()和putc()函数逐字符复制内容。
最低0.47元/天 解锁文章
1210

被折叠的 条评论
为什么被折叠?



