learning c in mint

Forum rules
Before you post please read this

learning c in mint

Postby deepakrathore23 on Wed Oct 12, 2011 5:43 am

i wish to learn c using mint...i had a cygwin installed on my windowa for this purpose,it created unix like environment....
wat do i need to have a cygwin like app...or since linux is based on unix i can use terminal directly?
deepakrathore23
Level 1
Level 1
 
Posts: 21
Joined: Wed May 18, 2011 1:37 pm

Linux Mint is funded by ads and donations.
 

Re: learning c in mint

Postby dagon on Wed Oct 12, 2011 5:56 am

No cygwin needed. For basic, "Hello world programs", just compile it and run...
Image
User avatar
dagon
Level 7
Level 7
 
Posts: 1690
Joined: Mon Dec 06, 2010 4:33 am
Location: Kungälv, Sweden

Re: learning c in mint

Postby deepakrathore23 on Wed Oct 12, 2011 6:07 am

wat abt text editor...?
m a newb u see...ihv gcc and lib installed,text editor i dont hv the idea....
the main terminal cant be used to write programs...am i correct?
deepakrathore23
Level 1
Level 1
 
Posts: 21
Joined: Wed May 18, 2011 1:37 pm

Re: learning c in mint

Postby dagon on Wed Oct 12, 2011 6:22 am

deepakrathore23 wrote:the main terminal cant be used to write programs...am i correct?

Not really. You can use one of the terminal based text editors but don't.
Just use an ordinary text editor like gedit and compile from the console to start with so you learn
the basics. Find yourself a basic c tutorial and it will surely mention this.

Happy hacking! :D
Image
User avatar
dagon
Level 7
Level 7
 
Posts: 1690
Joined: Mon Dec 06, 2010 4:33 am
Location: Kungälv, Sweden

Re: learning c in mint

Postby xenopeek on Wed Oct 12, 2011 8:44 am

A short introduction to using the gcc compiler: http://cs.acadiau.ca/~jdiamond/comp2103/beginner-tutorials/LinuxTutorialGcc.html#Using%20gcc:

For general information about programming in C there are lots of good books and resources (a start might be: http://www.cprogramming.com/). It still find I learned the most about basics of the language with The C Programming Language, and its exercises.

If you want to programming not general C code, that will run on Windows, Linux and others, but you want to specifically program for Linux, you can not beat The Linux Programming Interface book. No Starch have a lot of good Linux books :wink: Their Autotools book might be useful also.

For programming GUIs on GNOME, you want Glade. For programming games and such, use SDL. The better IDEs have GUI design built-in (such as Anjuta).

As dagon pointed out you can use just gedit to edit .c and .h files; it will do proper syntax highlighting if you give it those extensions. If you want you can use an IDE (perhaps advisable for large projects). Some IDEs: http://linuxmafia.com/faq/Devtools/ides.html. It will take some trial & error on your part to find one that does what you need. Most can be installed from the Software Manager directly, without need to go download it yourself or anything so archaic.

Do yourself a favor, and use a revision control system for your source code (or at the very least take a daily backup of your source code files), so that you can always rollback on changes you made if needed. CVS / Subversion / Git / Bazaar, again a lot of options. Just pick one; choice also depends on if you want to write just yourself, or help out on other projects / get others to help you. Git is used a lot for open source projects.
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14505
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: learning c in mint

Postby DrHu on Wed Oct 12, 2011 2:27 pm

Code::Blocks is a nice IDE (Integrated development Environment)
http://www.codeblocks.org/
    It is also cross-platform being based on the Wxwidgets library..
http://www.cprogramming.com/code_blocks/
--a tutorial on C..

It is also the C++ variety, although you can usually ignore that and code in plain C, rather than the object based C++
User avatar
DrHu
Level 16
Level 16
 
Posts: 6588
Joined: Wed Jun 17, 2009 8:20 pm

Re: learning c in mint

Postby deepakrathore23 on Wed Oct 12, 2011 3:53 pm

thanx a lot people.....
deepakrathore23
Level 1
Level 1
 
Posts: 21
Joined: Wed May 18, 2011 1:37 pm

Re: learning c in mint

Postby Moggertron on Wed Oct 12, 2011 7:04 pm

Two books I've read recently recommended using VI for writing my bash scripts and programming. Am I missing something? I would have thought gedit like mentioned above would be a more user friendly alternative. Is there something special about VI that I should stick with it and learn to use it? Sorry about hijack but may also assist original poster
Moggertron
Level 1
Level 1
 
Posts: 30
Joined: Sat Aug 13, 2011 9:19 pm
Location: Mandurah WA

Re: learning c in mint

Postby dagon on Wed Oct 12, 2011 8:23 pm

Moggertron wrote:Two books I've read recently recommended using VI for writing my bash scripts and programming. Am I missing something? I would have thought gedit like mentioned above would be a more user friendly alternative. Is there something special about VI that I should stick with it and learn to use it? Sorry about hijack but may also assist original poster

Personally I just found vi (vim, joe etc.) confusing. Use a modern editor/IDE.
Am I missing something?

The way I see it. No. Maybe if you have to find your way around an older machine.
When I first tried Linux some ten years ago there was no function to automatically mount a USB-flash drive automatically. You had to pop it in
there and then mount it from the comman line. when I asked people why it wouldn't do this automatically since it looked like a modern
grafical desktop, I just got the answer that this was the way it was done under Linux... Use whatever programs you find suitable for your
needs. I highly doubt that vi is going to be one of them... ;)
Personally I use Geany for my, rather modest, programming needs and I highly recommend it.
Image
User avatar
dagon
Level 7
Level 7
 
Posts: 1690
Joined: Mon Dec 06, 2010 4:33 am
Location: Kungälv, Sweden

Re: learning c in mint

Postby Moggertron on Wed Oct 12, 2011 8:41 pm

Thanks Dagon. I wasn't sure if there was some amazing feature that I was missing out on by not using it. I didn't think so, but I've been wrong in the past.
Moggertron
Level 1
Level 1
 
Posts: 30
Joined: Sat Aug 13, 2011 9:19 pm
Location: Mandurah WA

Re: learning c in mint

Postby thaimann on Wed Nov 09, 2011 9:54 pm

For an editor I like BlueFish, but gedit will work. As your programs get bigger you will appreciate the feature set in BlueFish though. So just enter your basic program in the editor of your choice and then save it to some subdirectory like ~/Documents/MyCPrg" then start a Bash prompt and do a cd to that directory and just issue a command similar to "gcc -o myprg myprg.c".

If there are no compile errors you can then run it with a "./myprg"
thaimann
Level 1
Level 1
 
Posts: 30
Joined: Thu Aug 18, 2011 9:36 am

Re: learning c in mint

Postby Moggertron on Fri Nov 25, 2011 7:50 am

thaimann wrote:For an editor I like BlueFish, but gedit will work. As your programs get bigger you will appreciate the feature set in BlueFish though. So just enter your basic program in the editor of your choice and then save it to some subdirectory like ~/Documents/MyCPrg" then start a Bash prompt and do a cd to that directory and just issue a command similar to "gcc -o myprg myprg.c".

If there are no compile errors you can then run it with a "./myprg"


I've added my Script folder that is inside my Home folder to the path searched for programs. So I can skip the ./ part of the command.
Moggertron
Level 1
Level 1
 
Posts: 30
Joined: Sat Aug 13, 2011 9:19 pm
Location: Mandurah WA

Linux Mint is funded by ads and donations.
 

Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 2 guests