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.
|
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 |
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 |
thank you
I still need some basic knowledge before I can do other things |
Quote:
what If I want to compile C++, what should I do? type in the command lines? |
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 .
|
wow!! fast response. I've learned lots of things since yesterday!! Great forum!!
|
Get your hands on a book such as "SAMS Teach yourself C++ for Linux in 21 days", is very helpful for a total noob.
|
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 |
All times are GMT -5. The time now is 11:23 PM. |