learning c in mint

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
deepakrathore23

learning c in mint

Post by deepakrathore23 »

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?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
dagon
Level 7
Level 7
Posts: 1655
Joined: Mon Dec 06, 2010 4:33 am
Location: Kungälv, Sweden
Contact:

Re: learning c in mint

Post by dagon »

No cygwin needed. For basic, "Hello world programs", just compile it and run...
deepakrathore23

Re: learning c in mint

Post by deepakrathore23 »

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?
dagon
Level 7
Level 7
Posts: 1655
Joined: Mon Dec 06, 2010 4:33 am
Location: Kungälv, Sweden
Contact:

Re: learning c in mint

Post by dagon »

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
User avatar
xenopeek
Level 25
Level 25
Posts: 29510
Joined: Wed Jul 06, 2011 3:58 am

Re: learning c in mint

Post by xenopeek »

A short introduction to using the gcc compiler: http://cs.acadiau.ca/~jdiamond/comp2103 ... ing%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.
Image
DrHu

Re: learning c in mint

Post by DrHu »

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++
deepakrathore23

Re: learning c in mint

Post by deepakrathore23 »

thanx a lot people.....
Moggertron

Re: learning c in mint

Post by Moggertron »

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
dagon
Level 7
Level 7
Posts: 1655
Joined: Mon Dec 06, 2010 4:33 am
Location: Kungälv, Sweden
Contact:

Re: learning c in mint

Post by dagon »

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.
Moggertron

Re: learning c in mint

Post by Moggertron »

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.
thaimann

Re: learning c in mint

Post by thaimann »

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"
Moggertron

Re: learning c in mint

Post by Moggertron »

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.
Locked

Return to “Scripts & Bash”