By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,958 Members | 1,156 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,958 IT Pros & Developers. It's quick & easy.

Getting started with C on my Linux machine.

P: n/a
I would like to get started with programming in C, but I cant get it to
work, I do not need any compiler or such.
Only a basic explanation of the first program Hello World that print
"Hello World" on the screen.

Greetings Tobias

Jul 26 '06 #1
Share this Question
Share on Google+
13 Replies


P: n/a
ThaDoctor wrote:
>
I would like to get started with programming in C,
but I cant get it to
work, I do not need any compiler or such.
Only a basic explanation of the first program Hello World that print
"Hello World" on the screen.
The whole point of the Hello World program,
is to gain enough familiarity with your C implementation
to write, translate, and execute a C program.

--
pete
Jul 26 '06 #2

P: n/a

pete skrev:
ThaDoctor wrote:

I would like to get started with programming in C,
but I cant get it to
work, I do not need any compiler or such.
Only a basic explanation of the first program Hello World that print
"Hello World" on the screen.

The whole point of the Hello World program,
is to gain enough familiarity with your C implementation
to write, translate, and execute a C program.

--
pete
and after I have written and cmpiled how do I run the program under
linux ?

Jul 26 '06 #3

P: n/a

pete skrev:
ThaDoctor wrote:

I would like to get started with programming in C,
but I cant get it to
work, I do not need any compiler or such.
Only a basic explanation of the first program Hello World that print
"Hello World" on the screen.

The whole point of the Hello World program,
is to gain enough familiarity with your C implementation
to write, translate, and execute a C program.

--
pete
And after this how do I run the program under linux ?

Jul 26 '06 #4

P: n/a
ThaDoctor <To*********@gmail.comwrote:
and after I have written and cmpiled how do I run the program under
linux ?
<ot>
Run a.out. man gcc for details, assuming that's your compiler.
Take further questions to comp.unix.programmer.
</ot>

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Jul 26 '06 #5

P: n/a

ThaDoctor wrote:
pete skrev:
ThaDoctor wrote:
I would like to get started with programming in C,
but I cant get it to
work, I do not need any compiler or such.
Only a basic explanation of the first program Hello World that print
"Hello World" on the screen.
The whole point of the Hello World program,
is to gain enough familiarity with your C implementation
to write, translate, and execute a C program.

and after I have written and cmpiled how do I run the program under
linux ?
% gcc hello_world.c -o hi # compile the program
% ./hi # execute the program

In the above, '%' represents your command prompt.
Your questions are not really appropriate in this
newsgroup, but once you've figured out the basics
and have questions about the C language, those
questions will probably be topical. Make sure
to read the faq:

http://www.c-faq.com/

Jul 26 '06 #6

P: n/a
cp
Go to the place where you "saved" the compiled file and write: ./<program>
That is: dotSLASH<program-name>
Jul 26 '06 #7

P: n/a
ThaDoctor wrote:
>
pete skrev:
>ThaDoctor wrote:
>
I would like to get started with programming in C,
but I cant get it to
work, I do not need any compiler or such.
Only a basic explanation of the first program Hello World that print
"Hello World" on the screen.

The whole point of the Hello World program,
is to gain enough familiarity with your C implementation
to write, translate, and execute a C program.

--
pete

And after this how do I run the program under linux ?
The same way you run any other program in Linux, which, if
you ran the compiler, you presumably already know.

--
Chris "programPathOrNameAlongPath RETURN" Dollin
A rock is not a fact. A rock is a rock.

Jul 27 '06 #8

P: n/a

Chris Dollin wrote:
ThaDoctor wrote:

pete skrev:
ThaDoctor wrote:

I would like to get started with programming in C,
but I cant get it to
work, I do not need any compiler or such.
Only a basic explanation of the first program Hello World that print
"Hello World" on the screen.

The whole point of the Hello World program,
is to gain enough familiarity with your C implementation
to write, translate, and execute a C program.

--
pete
And after this how do I run the program under linux ?

The same way you run any other program in Linux, which, if
you ran the compiler, you presumably already know.
How does it follow from running the compiler by invoking
"gcc hello.c" that one runs the program by typing "./a.out"?
>
--
Chris "programPathOrNameAlongPath RETURN" Dollin
A rock is not a fact. A rock is a rock.
Jul 27 '06 #9

P: n/a
me********@aol.com wrote:
>
Chris Dollin wrote:
>ThaDoctor wrote:
>
pete skrev:

ThaDoctor wrote:

I would like to get started with programming in C,
but I cant get it to
work, I do not need any compiler or such.
Only a basic explanation of the first program Hello World that print
"Hello World" on the screen.

The whole point of the Hello World program,
is to gain enough familiarity with your C implementation
to write, translate, and execute a C program.

--
pete

And after this how do I run the program under linux ?

The same way you run any other program in Linux, which, if
you ran the compiler, you presumably already know.

How does it follow from running the compiler by invoking
"gcc hello.c" that one runs the program by typing "./a.out"?
Because in both cases -- more than both, since the OP presumably
knows more Linux commands than just `gcc` -- one types an
abbreviated version of the program's name.

The /real/ answer to the OPs question is, I suppose, "Usenet
is not, and is not intended to be, a substitute for an
actual person bootstrapping you."

--
Chris "finder" Dollin
"The path to the web becomes deeper and wider" - October Project

Jul 27 '06 #10

P: n/a
me********@aol.com wrote:
Chris Dollin wrote:
ThaDoctor wrote:
>
pete skrev:
>
>ThaDoctor wrote:
>
I would like to get started with programming in C,
but I cant get it to
work, I do not need any compiler or such.
Only a basic explanation of the first program Hello World that print
"Hello World" on the screen.
>>
>The whole point of the Hello World program,
>is to gain enough familiarity with your C implementation
>to write, translate, and execute a C program.
>>
>--
>pete
>
And after this how do I run the program under linux ?
The same way you run any other program in Linux, which, if
you ran the compiler, you presumably already know.

How does it follow from running the compiler by invoking
"gcc hello.c" that one runs the program by typing "./a.out"?
umteenth_out_of_topic_post {

Because the compiler as a default will create an executable
with name a.out (derived from "assembler output") in your
working directory. In Unix a single dot (.) is shorthand for
your working directory. So typing "./a.out" (without the quotes)
tells to the operating system to execute the file in the working
directory with name a.out Of course such a file will be created
only if the compilation completed without poblems.

If dot (.) appears in your PATH variable then you can simply type
a.out If you didn't understand the last sentence you can safely
ignore it.
}

Christopher Benson-Manica wrote:
ThaDoctor <To*********@gmail.comwrote:
and after I have written and cmpiled how do I run the program under
linux ?

<ot>
Run a.out. man gcc for details, assuming that's your compiler.
Take further questions to comp.unix.programmer.
</ot>
I don't think that a beginner will get much out of the gcc man page.
Bill Pursell wrote:
ThaDoctor wrote:
pete skrev:
ThaDoctor wrote:
I would like to get started with programming in C,
but I cant get it to
work, I do not need any compiler or such.
Only a basic explanation of the first program Hello World that print
"Hello World" on the screen.
>
The whole point of the Hello World program,
is to gain enough familiarity with your C implementation
to write, translate, and execute a C program.
and after I have written and cmpiled how do I run the program under
linux ?

% gcc hello_world.c -o hi # compile the program
% ./hi # execute the program
There is a pitfall here in that if there's already a file with name
"hi",
then the compilation command will silently overwrite it.

Spiros Bousbouras

Jul 27 '06 #11

P: n/a

sp****@gmail.com wrote:
me********@aol.com wrote:
Chris Dollin wrote:
ThaDoctor wrote:
>

pete skrev:

ThaDoctor wrote:

I would like to get started with programming in C,
but I cant get it to
work, I do not need any compiler or such.
Only a basic explanation of the first program Hello World that print
"Hello World" on the screen.
>
The whole point of the Hello World program,
is to gain enough familiarity with your C implementation
to write, translate, and execute a C program.
>
--
pete

And after this how do I run the program under linux ?
>
The same way you run any other program in Linux, which, if
you ran the compiler, you presumably already know.
How does it follow from running the compiler by invoking
"gcc hello.c" that one runs the program by typing "./a.out"?

umteenth_out_of_topic_post {

Because the compiler as a default will create an executable
with name a.out
But because it is a default, there is no reason to assume that
a new user would know that. If the syntax of the compiler forced
you to specify a destination file, such as "gcc hello.c a.out",
then it would follow that the user would know what the output
file is because he had to type it. When defaults are involved,
it does not follow that a user knows how to run the program
since he knew how to run the compiler.
(derived from "assembler output") in your
working directory. In Unix a single dot (.) is shorthand for
your working directory. So typing "./a.out" (without the quotes)
tells to the operating system to execute the file in the working
directory with name a.out
That wasn't what I was asking. I asked how does knowing how
to run the compiler without the leading "./" infer that one must
preceed a.out with "./"?
Of course such a file will be created
only if the compilation completed without poblems.

If dot (.) appears in your PATH variable then you can simply type
a.out If you didn't understand the last sentence you can safely
ignore it.
}

Christopher Benson-Manica wrote:
ThaDoctor <To*********@gmail.comwrote:
and after I have written and cmpiled how do I run the program under
linux ?
<ot>
Run a.out. man gcc for details, assuming that's your compiler.
Take further questions to comp.unix.programmer.
</ot>

I don't think that a beginner will get much out of the gcc man page.
Bill Pursell wrote:
ThaDoctor wrote:
pete skrev:
>
ThaDoctor wrote:
I would like to get started with programming in C,
but I cant get it to
work, I do not need any compiler or such.
Only a basic explanation of the first program Hello World that print
"Hello World" on the screen.

The whole point of the Hello World program,
is to gain enough familiarity with your C implementation
to write, translate, and execute a C program.
>
and after I have written and cmpiled how do I run the program under
linux ?
% gcc hello_world.c -o hi # compile the program
% ./hi # execute the program

There is a pitfall here in that if there's already a file with name
"hi",
then the compilation command will silently overwrite it.

Spiros Bousbouras
Jul 27 '06 #12

P: n/a
On 27 Jul 2006 10:29:04 -0700, "me********@aol.com" <me********@aol.com>
wrote:
>That wasn't what I was asking. I asked how does knowing how
to run the compiler without the leading "./" infer that one must
preceed a.out with "./"?
This isn't a compiler issue, it's a matter of whether the current
directory is in the PATH variable. When I want a program to execute
without the leading "./", I move it to /usr/local/bin.

Clifford Stern
ax***@lafn.org
Aug 1 '06 #13

P: n/a

Clifford Stern wrote:
On 27 Jul 2006 10:29:04 -0700, "me********@aol.com" <me********@aol.com>
wrote:
That wasn't what I was asking. I asked how does knowing how
to run the compiler without the leading "./" infer that one must
preceed a.out with "./"?

This isn't a compiler issue,
I didn't say it was.
it's a matter of whether the current
directory is in the PATH variable.
I didn't ask why it works the way it does.
When I want a program to execute
without the leading "./", I move it to /usr/local/bin.
No one asked what you want. The question was

"How does knowing how to run the compiler infer that
one knows how to run the program?"

Please try to keep up.
>
Clifford Stern
ax***@lafn.org
Aug 1 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.