如何运行(和编译)带有gcc参数的C文件?

Sem*_*ger -1 c command-line gcc

我认为这是一个非常简单的问题,但我对命令行的经验较少.我有一个我想要运行的旧C程序.它显示以下文本:

/*      This is a stand-alone program intended to generate ...  It is called*/
/*      as follows:                                                         */
/*                                                                          */
/*          tw_r2fft N > outputfile.c                                       */ 
/*      This program will generate the ... array 'w'                        */
/*      and output the result to the display.  Redirect the                 */
/*      output to a file as shown above.                                    */
Run Code Online (Sandbox Code Playgroud)

我试过(在cmd中):

gcc tw_r2fft.c 1024 > outputfile.c
Run Code Online (Sandbox Code Playgroud)

gcc的错误消息是:

gcc: 1024: No such file or directory
Run Code Online (Sandbox Code Playgroud)

我尝试了一些变化但没有成功.

izo*_*ica 9

我相信文档意味着你应该首先编译和构建程序,然后用参数调用可执行文件.因此,在您的情况下,您需要执行以下操作:

gcc tw_r2fft.c -o tw_r2fft 
./tw_r2fft 1024 > outputfile.c
Run Code Online (Sandbox Code Playgroud)


buc*_*buc 5

尝试将 C 程序编译为可执行二进制文件:

gcc -o tw_r2fft tw_r2fft.c
Run Code Online (Sandbox Code Playgroud)

然后使用正确的命令行参数启动二进制文件:

./tw_r2fft 1024 >outputfile.c
Run Code Online (Sandbox Code Playgroud)

然后你也可以编译并运行你的输出文件::)

gcc -o test outputfile.c
./test
Run Code Online (Sandbox Code Playgroud)