LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-24-2005, 11:25 AM   #1
objorkum
Member
 
Registered: Aug 2003
Location: Norway
Distribution: Slackware 10.0
Posts: 231

Rep: Reputation: 30
Learn C/C++


And want to learn how to program in C/C++, and later I want to use it to create some simple GTK apps. I guess C is the best language then?

Is there any good online books/tutorials that I can start with?
 
Old 07-24-2005, 12:27 PM   #2
lowpro2k3
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
GTK programming in C is very complex for a beginning programmer. I would highly recommend you learn C for longer than you think you should before moving into GUI programming. I have the book "The Official Gnome 2 Developers Guide", let me take a quote from the Introduction chapter:



Quote:
... you should have:
  • Firm programming experience in C, including pointers, dynamically allocated memory data structures, and pointers to functions. You should also be familiar with enumeration types and bit fields [Kernighan].
  • A solid grasp of pointers to pointers (** types), where to use them, and how to extract and use the address of a pointer.
  • Understanding of C macros and the C preprocessor
  • Fundamental understanding of Unix: processes, libraries, search paths and so on.
Don't get me wrong, none of that is too difficult, but it definately takes some practice in C programming, the amount of time would be different for everyone, but I would say if you spend alot of time in C and asking questions on various programming forums you could probably get up to speed in 6 months to a year. You could also start programming from a GTK book immediately if you wanted, sure you could get things to work but you wouldn't have nearly the understanding of it that you should.

As for which C book to buy, I started with C++ and moved back to C, so I'm the wrong person to ask on where to start learning C. I started learning C++ from the book 'C++ Primer Plus: 4th Edition' by Stephen Prata, and I know he has written the same book for C as well. I really liked the book and still reference it every once in a while. As your skills progress, you'll want to pick up 'The C Programming Language' by Kernighan and Ritchie.

Good luck,

- lowpro2k3
 
Old 07-24-2005, 12:31 PM   #3
NCC-1701&NCC-1701-D
Member
 
Registered: May 2005
Distribution: Debian Woody,Knoppix
Posts: 88

Rep: Reputation: 16
The ultimate C book: "The C Programming Language, Second Edition" Kernighan and Ritchie prentice Hall
Tutor: www.its.strath.ac.uk/courses/c/

THE ultimate C++ tutorial:
www.cplusplus.com/doc/tutorial/
Hope it helped!
 
Old 07-24-2005, 01:00 PM   #4
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
Quote:
The ultimate C book: "The C Programming Language, Second Edition" Kernighan and Ritchie prentice Hall
this looks much like the gnu c programming tutorial. good tutorial some bad linux only code used tho. YOU HAVE BEEN WARNED


i started learning a year ago then started just recently relearning things and having a better understanding now then i did back then. I have tried gtk programming and after creating a program with 2 buttons decided i better learn more about C before trying anything further. gtk is eazier then i would say xlib is but can still be very confusing to a new programmer like myslef.
 
Old 07-24-2005, 03:04 PM   #5
objorkum
Member
 
Registered: Aug 2003
Location: Norway
Distribution: Slackware 10.0
Posts: 231

Original Poster
Rep: Reputation: 30
Thanks for your replies. I have actually considered to buy "The ultimate C book: "The C Programming Language, Second Edition" Kernighan and Ritchie", and I think I will buy it now.

So, the right thing to do for me if I want to learn to program simple GTK apps is to first learn C, and then learn GTK? And yes, I'm prepared to spend some time learning C first.
 
Old 07-24-2005, 03:33 PM   #6
lowpro2k3
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
How much programming experience do you have? I dont think 'The C Programming Language' is suitable for non-programmers. I think you would just end up getting frustrated at TCPL, you should look for more of a beginners book instead, just my two cents.
 
Old 07-24-2005, 03:37 PM   #7
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
To master GTK it requires quite good C knowledge (especially things like pointers). There are tutorials, however, that start with very simple examples, so you can check them just after 2-3 days with C. The time may vary depending on the fact if you know any programming language (learning 2nd, 3rd... is much easier than first) or not.
 
Old 07-25-2005, 07:18 AM   #8
objorkum
Member
 
Registered: Aug 2003
Location: Norway
Distribution: Slackware 10.0
Posts: 231

Original Poster
Rep: Reputation: 30
Well, I don't have much experience. I do know PHP very well...

Do you have any beginners-books to recommend?
 
Old 07-25-2005, 01:27 PM   #9
lowpro2k3
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
I'm really a fan of the '[insert language] Primer Plus' books. You could try 'C Primer Plus' by Stephen Prata.

http://www.amazon.com/exec/obidos/tg...books&n=507846
 
Old 07-25-2005, 03:01 PM   #10
slzckboy
Member
 
Registered: May 2005
Location: uk - Reading
Distribution: slackware 14.2 kernel 4.19.43
Posts: 462

Rep: Reputation: 30
Hi

my two cents..okay more like 30 cents..

I have been programming for just over a year and am still very much on the learning curve.
However I feel that I have enough experience to lend you a valid opinion.

My first introduction to C was through K&R mentioned above.
B4 that; my only other programming experience was some basic college assembly language

anyway..

I have a couple of other books on C but the beauty of The C Programming Language, Second Edition" Kernighan and Ritchie prentice Hall is that it gives a feel for the fundermentals of the language and how to approach a C program very early on.

Unlike other books that give you pages and pages of syntax on basic functions .Details which IMHo you are better off picking up as you go on ?!?!

I also don't feel that C is too hard as a first language.All though I do concede that it takes some mastering(I'll lket you know wen I have),but you can have fun writing useful unix/linux programs on the way.

i think you may wish to humble your ambitions slighty at first ,but you WILL get there if it is what u want to do.

ta.

slzckboy.
 
Old 07-25-2005, 08:35 PM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,363

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
I highly recommend this book to start learning C: http://www.amazon.com/exec/obidos/tg...82263?v=glance
It's less terse than K&R.
K&R is fine as a reference once you know the basics of C.
 
Old 07-26-2005, 01:32 AM   #12
enemorales
Member
 
Registered: Jul 2004
Location: Santiago, Chile
Distribution: Ubuntu
Posts: 410

Rep: Reputation: 31
HI!

Well, also, depending on your priorities, you can program for GTK using languages which are supposed to be simpler, like Python. I wouldn't be surprised if there are PHP binding for GTK! In that way you will be learning a lot about GTK. On the other hand, if your priority is C, then a good book (like those that have been posted) and the many tutorials on the internet will suffice.

HTH!
 
Old 07-26-2005, 04:43 AM   #13
craigs1987
Member
 
Registered: May 2004
Location: England
Distribution: SuSE linux 10.0 OSS
Posts: 78

Rep: Reputation: 15
I found Ivor Hortons book, Beginning C (Third Edition) very helpful. Though I moved on to his ANSI C++ rather than move to GTK+.
 
Old 07-26-2005, 07:16 AM   #14
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally posted by craigs1987
I found Ivor Hortons book, Beginning C (Third Edition) very helpful. Though I moved on to his ANSI C++ rather than move to GTK+.
Just to say, I recommend Horton as well. I have his books on C++ and Java and I find them both easy to follow, so I assume "Beginning C" would be the same .
 
Old 07-30-2005, 07:58 AM   #15
objorkum
Member
 
Registered: Aug 2003
Location: Norway
Distribution: Slackware 10.0
Posts: 231

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by enemorales
HI!

Well, also, depending on your priorities, you can program for GTK using languages which are supposed to be simpler, like Python. I wouldn't be surprised if there are PHP binding for GTK! In that way you will be learning a lot about GTK. On the other hand, if your priority is C, then a good book (like those that have been posted) and the many tutorials on the internet will suffice.

HTH!
I think maybe I'll start learning Python and then start learning PyGTK. It seems not so difficult.
 
  


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
The best way to learn? iz3r Programming 7 02-06-2005 11:00 PM
Do you really need to learn C before C++? qcoder Programming 31 12-04-2003 10:10 AM
What should i get to learn? Any Solaris / OpenSolaris 1 02-18-2003 06:19 PM
I would like to learn how to do it tournesol Linux From Scratch 2 10-07-2002 10:07 PM
How to learn more? R2RO Linux - Software 5 08-31-2002 08:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:15 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