vc ++ 6.0中的命令行参数 [英] command line argument through vc++ 6.0

查看:304
本文介绍了vc ++ 6.0中的命令行参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生您好,
我在这里发送原始帖子.
#include"stdio.h"

main(int argc,char * argv [])
{
文件* fs,* ft;
char ch;
如果(argc!= 3)
{
puts(参数数量不正确");
exit();
}
fs = fopen(argv [1],"r");
如果(fs == NULL)
{
puts(无法打开源文件");
exit();
}
ft = fopen(argv [2],"w");
如果(ft == NULL)
{
puts(无法打开目标文件");
fclose(fs);
exit();
}
而(1)
{
ch = fgetc(fs);
如果(ch == EOF)
休息;
其他
fputc(ch,ft);
}
fclose(fs);
fclose(ft);
}
当我在vc ++编译器中运行时,它总是向我显示有关参数数量不正确"的信息.
但是我将如何通过命令提示符运行,以将一个文件复制到另一个文件,因为它始终显示以下语句.

我们如何配置vc ++ 6.0以通过命令提示符发送参数.
IE;通过vc ++进行命令行参数设置的过程是什么.
我们将如何发送自变量?

Hello sir,
here i m sending the original post.
#include "stdio.h"

main ( int argc, char *argv[ ] )
{
FILE *fs, *ft ;
char ch ;
if ( argc != 3 )
{
puts ( "Improper number of arguments" ) ;
exit( ) ;
}
fs = fopen ( argv[1], "r" ) ;
if ( fs == NULL )
{
puts ( "Cannot open source file" ) ;
exit( ) ;
}
ft = fopen ( argv[2], "w" ) ;
if ( ft == NULL )
{
puts ( "Cannot open target file" ) ;
fclose ( fs ) ;
exit( ) ;
}
while ( 1 )
{
ch = fgetc ( fs ) ;
if ( ch == EOF )
break ;
else
fputc ( ch, ft ) ;
}
fclose ( fs ) ;
fclose ( ft ) ;
}
when i run in vc++ compiler it always show to me about that "Improper number of arguments".
but how i will run through command prompt to copy one file to another, as it always shows the following statement.

How we configure vc++ 6.0 to send arguments through command prompt.
i.e; what will be the procedure to make command line argument through vc++.
How will we send argument ??

推荐答案

您应该已经编辑了原始帖子.我想,您可以指定命令行参数来传递项目设置.另一个合理的选择是编写一些仅在调试模式下运行的代码,该代码使用一些硬编码的参数进行测试.
You should have edited your original post. You can specify the command line arguments to pass in the project settings, I thought. Another logical option is to write some code that only runs in debug mode, that uses some hard coded arguments, for testing.


这篇关于vc ++ 6.0中的命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆