473,765 Members | 2,172 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting started with C on my Linux machine.

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
13 1770
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*********@gm ail.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.progr ammer.
</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

sp****@gmail.co m 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*********@gm ail.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.progr ammer.
</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
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1530
by: cara_little | last post by:
Good Morning, I'm trying to get started with the Enterprise Library to evaluate it and recommend to the rest of the developers in the company. However, I'm having a heck of a time getting started and must be missing something. All of our development is completed in VB. I have installed Enterprise Library on my machine - however I can't compile the project. Is the code only available in C#? which means I have to have C# installed just to...
80
5280
by: Bibby | last post by:
Hi, I'm interested in getting started in the programming world. I've dabbled in C, C++ and VB6. Which would be the best language to focus my attention to regarding the following considerations: Hireability Portability Flexibility The likely candidates seem to be Java, VB.Net, C, C++, C#.
0
1550
by: Peter Chant | last post by:
I hope no one minds me running this past them. I'm running a linux machine with with apache, php and mysql. This is not accessable from the internet. I want a server that is visable to the internet. For that purpose I am running a user mode linux machine and using apache on that as the external looking web server. This means that stuff I want to see on the outside is on a copy of apache that is doing little and does not get messed...
2
1167
by: tom c | last post by:
In asp.net 2.0 I found this great list of getting started walkthroughs that take you through what you need to know step by step. http://msdn2.microsoft.com/en-us/library/ms186109.aspx Now I have to go back and do a project in version 1.1 and I can not find a similar page that lists the walkthroughs in order that would teach my how to do things in the older version. Do you know of any such list?
4
1631
pntkiran
by: pntkiran | last post by:
i have on project in php. i want to run that project on linux machine. so to execute that project which steps required. is there any need to configure httpd.conf file if then tell me all step required to run project with example. thanks in advance.
1
1814
by: rocket1356 | last post by:
Anyone know what component or where to get a tutorial on how to connect to a LINUX machine using a VB app? I am trying to create a WIN32 Visual Basic application that communicates with a LINUX machine. I will need to open and read some file info from the LINUX machine and display it in the application. If change is need I will write the change to the file. I cannot install SAMBA on the customer's computer. The LINUX server has an SSH...
1
4743
by: =?Utf-8?B?Q29kZVNsaW5nZXI=?= | last post by:
I plan to build my own 2008 Server/Hyper-V system and will not be using one of the tested Dell or HP systems from the release notes and could use some pointers as to my assumnptions and answers to a few questions. Some getting started with Hyper-V assumptions. Please tell me if I am off base here. 1. Any recent Intel quad core processor has the needed x64 architecture with hardware assisted virtualization and data execution protection...
3
2189
Banfa
by: Banfa | last post by:
So the title pretty much says it. I am attempting to switch to Linux but the printer attached to my machine must still be accessible by my wife who uses Windows. Alternatively attaching the printer to my wife's machine and accessing a printer on a Windows machine from Linux machine would work for us to if that is possible and the first option isn't.
1
2162
by: tvnaidu | last post by:
I have Linux machine and windows machine on same network, I want to keep Linux machine as CVS server and windows machine as CVS client, can I keep like that?. My development machine is windows machine, I want to do all check-in and check-out of all files from windows machine, but Linux as server, please let me know whether I can do like that?. appreciated.
1
1789
by: James Wright | last post by:
Hi, I am using oracle9i on Windows XP for my work. I have seen that sometimes oracle services(either listner or instance, sometimes both) are not getting started automatically on rebooting the machine. Though the services can be started manually after the reboot. I want to check what has gone wrong at oracle end. I have checked the alert file but that does not contain any information regarding this issue. Can anyone suggest any log file...
0
9398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9951
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5419
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.