1

I've been having a problem with compiling.

I used the following test C code below and saved it as test.c in Home folder.

#include <stdio.h>
int main()
{
  printf("Bruh!");
  return 0;
}

When I run in terminal the code

 gcc test.c -o test

I get nothing. Thank you

  • Did you run ./test? – muru Mar 22 '15 at 13:09
3

You are compiling the code, not running it, the correct procedure is:

  • Create the source file (test.c)
  • Compile it with gcc test.c -o test
  • Run it with ./test

Also you can make a oneliner with these commands:

gcc test.c -o test; ./test
0

Write Open a text editor and type the above mentioned "Hello World" code. Save this file as HelloWorld.c.

Compile Open command prompt and go to your current working directory where you saved your HelloWorld.c file. Compile your code by typing gcc HelloWorld.c in command prompt. Your program will compile successfully, If your program doesn't contain any syntax error. It will generate an a.out file.

Execute Now run your program by typing a.out in command prompt.

Output You will see "Hello World" printed on your console.

Source : Writing first C program, Hello world Program

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.