简体   繁体   English

在Mac的终端机上运行AC程序

[英]Run a c program in terminal on mac

I can compile c source into binary by going into terminal and type gcc <filename> . 我可以通过进入终端并输入gcc <filename>将c源代码编译为二进制。 This renders the output file in the respective directory. 这将在相应目录中呈现输出文件。 But what if I want to interact with the file? 但是,如果我想与文件交互怎么办? I have a simple c program which asks for user input then provides out based on my input. 我有一个简单的C程序,要求用户输入,然后根据我的输入提供。 How do I execute this code in terminal? 如何在终端中执行此代码?

The default filename is a.out . 默认文件名是a.out If you want to run it, just type ./a.out . 如果要运行它,只需键入./a.out

If you want a different filename use -o . 如果要使用其他文件名,请使用-o That is, run gcc -o MyOutName <filename> . 也就是说,运行gcc -o MyOutName <filename>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM