福大牛二爷 发表于 2012-11-29 16:11:14

int main(int argc, char **argv )

在开发板上有个程序,我要执行./ssss -o outfile infile然后执行。现在我想直接./ssss 就可以执行,自动读取infile文件,然后输出到 outfile文件,不知道,如何修改,网上有说:比如:test   a.c   b.c   t.c   

   argc   =   4      
   argv   =   "test"
   argv   =   "a.c"
   argv   =   "b.c"
   argv   =   "t.c"
但是我不知道那个 -o 算不算一个啊??
我的main()代码如下,请问具体如何修改啊,赐教下啊!int main( int argc, char **argv )
{
    x264_param_t param;
    cli_opt_t opt = {0};
    int ret = 0;
    FAIL_IF_ERROR( x264_threading_init(), "unable to initialize threading\n" )
#ifdef _WIN32
    _setmode(_fileno(stdin), _O_BINARY);
    _setmode(_fileno(stdout), _O_BINARY);
#endif
    GetConsoleTitle( originalCTitle, sizeof(originalCTitle) );
    /* Parse command line */
    if( parse( argc, argv, &param, &opt ) < 0 )
      ret = -1;
    /* Restore title; it can be changed by input modules */
    SetConsoleTitle( originalCTitle );
    /* Control-C handler */
    signal( SIGINT, sigint_handler );
    if( !ret )
      ret = encode( &param, &opt );
    /* clean up handles */
    if( filter.free )
      filter.free( opt.hin );
    else if( opt.hin )
      cli_input.close_file( opt.hin );
    if( opt.hout )
      cli_output.close_file( opt.hout, 0, 0 );
    if( opt.tcfile_out )
      fclose( opt.tcfile_out );
    if( opt.qpfile )
      fclose( opt.qpfile );
    SetConsoleTitle( originalCTitle );
    return ret;
}

福大牛二爷 发表于 2012-11-29 16:13:47

可以这样只操作么?
在main里面添加这几个:
argc=3
argv = outfile1.txt
argv = infile.txt
然后后面就的一样的额············
页: [1]
查看完整版本: int main(int argc, char **argv )