|
13 years ago 13 |
Install C and C++ Compilers in Mint
sudo aptitude install build-essential
This will install all the required packages for C and C++ compilers
Compiling Your first C Programs
Now you need to open first.c file
sudo gedit first.c
add the following lines save and exit the file
#include
int main()
{
printf(“Hello world\n”);
return 0;
}
Firstly compile the code using the following command
cc -c first.c
that would produce an object file you may need to add to the library.
then create an executable using the following command
cc -o first first.c
Now run this executable using the following command
./first
Output should show as follows
Hello, world
The tags are removed when you press edit, but you can fix the tutorial and save it and it will work. If you then choose to edit it once more you must make sure to also re-add whatever the editor takes away... :(
I don't know of any other way.
@dagon:exactly....
Ok. The code probably went missing after editing the text.
A bug in CKEditor:
http://drupal.org/node/1258998
1. #include
should be:
#include <stdio.h> // parenthesis won't render (html/xml???)
This explains the "undeclaired" part of the errors...
2. printf(“Hello world\n”)
The quotation marks is not plain ascii so that would
explain the "stray `\342'... etc.
We need a "Code component" thing for tutorials!
3. I'm with @frankh:
gcc -o name name.c
@parashargunjan:have you used conio.h header file?
first.c: In function ‘main’:
first.c:4: error: stray ‘\342’ in program
first.c:4: error: stray ‘\200’ in program
first.c:4: error: stray ‘\234’ in program
i m getting the below error plz help me out
first.c:4: error: ‘Hello’ undeclared (first use in this function)
first.c:4: error: (Each undeclared identifier is reported only once
first.c:4: error: for each function it appears in.)
first.c:4: error: expected ‘)’ before ‘world’
first.c:4: error: stray ‘\’ in program
first.c:4: error: stray ‘\342’ in program
first.c:4: error: stray ‘\200’ in program
first.c:4: error: stray ‘\235’ in program
very nice..
@MadhaniHarsh:
Nice job!
@trollboy:thankx,spread it if u like it
Nice simple introduction
@MadhaniHarsh:
Needless to say, I clicked on Promote Button when I added my first comments.
( And then I added you as my friend. I would be glad if you would also add me as your friend.)
@kazztan0325:thankx,i will keep this way of explaining.If u like it then please promote it.
Comment:
For the simplest compilation and use of C i Linux, it's not necessary to create an object file first. You can do gcc -o name name.c, and you'll immediately have an executable file.
I think this tutorial is very useful and easy to follow for beginners who are interested in C and C++ to start learning them.