Compiling C code in the terminal
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
add a comment |
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
Did you run./test
?
– muru
Mar 22 '15 at 13:09
add a comment |
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
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
compiling c
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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
add a comment |
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
answered Mar 22 '15 at 13:10
HelioHelio
5,44432950
5,44432950
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Aug 28 '16 at 21:06
Akbar KhanAkbar Khan
211
211
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Did you run
./test
?– muru
Mar 22 '15 at 13:09