LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-13-2005, 04:09 AM   #1
keiwu
Member
 
Registered: Feb 2005
Posts: 77

Rep: Reputation: 15
c programming hello world in linux? how?


I want to compile a "hello world" program written in C, the output I expeced was the text "hello world". I got no idea how to do it. I saw some others do it in school's computer, they run it in a place like dos and type some command line and the text "hello world" is displayed. I want to know what should I do if I am using fedora 3, and how can I get to that "dos" mode to do it? So new to linux, any helps are apprecated.
 
Old 02-13-2005, 04:15 AM   #2
__J
Senior Member
 
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
a console/xterm/konsole/gnome-terminal (basically, whatever command line you have, should be in your menu's somewhere) is your command line. open up a editor, put something like this in:

#include <stdio.h>

int main(int argc, char* argv[])
{
printf("hello world\n");
return 0;
}

and save the file to something like hello.c. then, in your command line, do (this is assuming you have a c compiler on your machine):

gcc hello.c -o hello

then to run the program:

./hello
 
Old 02-13-2005, 08:45 AM   #3
pradeepmenon777
Member
 
Registered: Jan 2004
Location: India
Distribution: Android 9.0.6
Posts: 123

Rep: Reputation: 16
i recommend you to buy some book on linux programming ,
so that you can slove all your problems on your own from now on. as you will face delay in replies in here

even i use to do this , refering books rather than doubt clearing every now and then in forums.

enjoy- this book is relly good - Linux programming bible by John Goerzen
 
Old 02-13-2005, 12:24 PM   #4
keiwu
Member
 
Registered: Feb 2005
Posts: 77

Original Poster
Rep: Reputation: 15
thank you
I still need some basic knowledge before I can do other things
 
Old 02-13-2005, 12:45 PM   #5
keiwu
Member
 
Registered: Feb 2005
Posts: 77

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by __J
a console/xterm/konsole/gnome-terminal (basically, whatever command line you have, should be in your menu's somewhere) is your command line. open up a editor, put something like this in:

#include <stdio.h>

int main(int argc, char* argv[])
{
printf("hello world\n");
return 0;
}

and save the file to something like hello.c. then, in your command line, do (this is assuming you have a c compiler on your machine):

gcc hello.c -o hello

then to run the program:

./hello
thank you!!
what If I want to compile C++, what should I do? type in the command lines?
 
Old 02-13-2005, 12:55 PM   #6
harken
Member
 
Registered: Jan 2005
Location: Between the chair and the desk
Distribution: Debian Sarge, kernel 2.6.13
Posts: 666

Rep: Reputation: 30
To compile C++ code you can use g++ instead of gcc with the same syntax: 'g++ hello.cpp -o hello'. But you don't need to do that until you don't write actual C++ code. If you want to see a list of C++ specific functions take a look here .
 
Old 02-13-2005, 01:00 PM   #7
keiwu
Member
 
Registered: Feb 2005
Posts: 77

Original Poster
Rep: Reputation: 15
wow!! fast response. I've learned lots of things since yesterday!! Great forum!!
 
Old 02-13-2005, 01:15 PM   #8
mebrelith
Member
 
Registered: Nov 2004
Location: Torreón, Coahuila, México
Distribution: Gentoo
Posts: 342
Blog Entries: 1

Rep: Reputation: 30
Get your hands on a book such as "SAMS Teach yourself C++ for Linux in 21 days", is very helpful for a total noob.
 
Old 02-13-2005, 02:13 PM   #9
pradeepmenon777
Member
 
Registered: Jan 2004
Location: India
Distribution: Android 9.0.6
Posts: 123

Rep: Reputation: 16
that is what i exactly wanted to say now!!
i thought that you had some concepts of linux

i take back my words
i would recommend the same as above
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hello in Linux World spanners LinuxQuestions.org Member Intro 4 10-25-2005 01:08 AM
Hello there in Linux world Lorend LinuxQuestions.org Member Intro 3 02-12-2005 08:00 AM
Hello, Linux World jokerbw LinuxQuestions.org Member Intro 1 06-14-2004 07:43 AM
hello linux world g3nzo Linux - Newbie 7 05-15-2002 02:16 PM
New At The Linux World neyromancer Linux - Newbie 13 07-13-2001 08:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration