开发者

printf doesn't return anything when using the Mac Terminal Utility

开发者 https://www.devze.com 2023-03-07 07:40 出处:网络
I wrote a small Hello World app. #include <stdio.h> int main(int argc, const char * argv[]) { print开发者_高级运维f(\"Hello World\\n\");

I wrote a small Hello World app.

#include <stdio.h>
int main(int argc, const char * argv[])
{
   print开发者_高级运维f("Hello World\n");


}

When I run

gcc fileName.c 

nothing is returned to the terminal. Can someone tell me what I'm doing wrong?


gcc is the compiler. it outputs a file called a.out unless specified otherwise using the -o flag, for example gcc -o myprogram fileName.c which will create an executable called myprogram from the source myFile.c.

To run your program write: ./a.out in the terminal


To compile an executable, you need to run:

gcc fileName.c -o app

That will create an executable file named app in the current directory. You then run that executable with:

./app
0

精彩评论

暂无评论...
验证码 换一张
取 消