天嵌 ARM开发社区

 找回密码
 注册
查看: 2370|回复: 1

int main(int argc, char **argv )

[复制链接]
福大牛二爷 发表于 2012-11-29 16:11:14 | 显示全部楼层 |阅读模式
在开发板上有个程序,我要执行./ssss -o outfile infile  然后执行。现在我想直接./ssss 就可以执行,自动读取infile文件,然后输出到 outfile文件,不知道,如何修改,网上有说:
  1. 比如:test   a.c   b.c   t.c   

  2.    argc   =   4      
  3.    argv[0]   =   "test"  
  4.    argv[1]   =   "a.c"  
  5.    argv[2]   =   "b.c"  
  6.    argv[3]   =   "t.c"
复制代码
但是我不知道那个 -o 算不算一个啊??
我的main()代码如下,请问具体如何修改啊,赐教下啊!
  1. int main( int argc, char **argv )
  2. {
  3.     x264_param_t param;
  4.     cli_opt_t opt = {0};
  5.     int ret = 0;
  6.     FAIL_IF_ERROR( x264_threading_init(), "unable to initialize threading\n" )
  7. #ifdef _WIN32
  8.     _setmode(_fileno(stdin), _O_BINARY);
  9.     _setmode(_fileno(stdout), _O_BINARY);
  10. #endif
  11.     GetConsoleTitle( originalCTitle, sizeof(originalCTitle) );
  12.     /* Parse command line */
  13.     if( parse( argc, argv, &param, &opt ) < 0 )
  14.         ret = -1;
  15.     /* Restore title; it can be changed by input modules */
  16.     SetConsoleTitle( originalCTitle );
  17.     /* Control-C handler */
  18.     signal( SIGINT, sigint_handler );
  19.     if( !ret )
  20.         ret = encode( &param, &opt );
  21.     /* clean up handles */
  22.     if( filter.free )
  23.         filter.free( opt.hin );
  24.     else if( opt.hin )
  25.         cli_input.close_file( opt.hin );
  26.     if( opt.hout )
  27.         cli_output.close_file( opt.hout, 0, 0 );
  28.     if( opt.tcfile_out )
  29.         fclose( opt.tcfile_out );
  30.     if( opt.qpfile )
  31.         fclose( opt.qpfile );
  32.     SetConsoleTitle( originalCTitle );
  33.     return ret;
  34. }
复制代码
 楼主| 福大牛二爷 发表于 2012-11-29 16:13:47 | 显示全部楼层
可以这样只操作么?
在main里面添加这几个:
argc=3
argv[1] = outfile1.txt
argv[2] = infile.txt
然后后面就的一样的额············
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号 )

GMT+8, 2024-5-5 08:29 , Processed in 1.078118 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表