Compiling C code in the terminal












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










share|improve this question

























  • Did you run ./test?

    – muru
    Mar 22 '15 at 13:09
















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










share|improve this question

























  • Did you run ./test?

    – muru
    Mar 22 '15 at 13:09














1












1








1


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










share|improve this question
















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







compiling c






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 18 '18 at 9:59









karel

60.6k13131155




60.6k13131155










asked Mar 22 '15 at 13:02









Najib AdanNajib Adan

1114




1114













  • Did you run ./test?

    – muru
    Mar 22 '15 at 13:09



















  • Did you run ./test?

    – muru
    Mar 22 '15 at 13:09

















Did you run ./test?

– muru
Mar 22 '15 at 13:09





Did you run ./test?

– muru
Mar 22 '15 at 13:09










2 Answers
2






active

oldest

votes


















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





share|improve this answer































    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






    share|improve this answer
























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "89"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f599863%2fcompiling-c-code-in-the-terminal%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      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





      share|improve this answer




























        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





        share|improve this answer


























          3












          3








          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





          share|improve this answer













          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






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 22 '15 at 13:10









          HelioHelio

          5,44432950




          5,44432950

























              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






              share|improve this answer




























                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






                share|improve this answer


























                  0












                  0








                  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






                  share|improve this answer













                  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







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 28 '16 at 21:06









                  Akbar KhanAkbar Khan

                  211




                  211






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Ask Ubuntu!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f599863%2fcompiling-c-code-in-the-terminal%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      數位音樂下載

                      When can things happen in Etherscan, such as the picture below?

                      格利澤436b