LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Learn C/C++ (https://www.linuxquestions.org/questions/programming-9/learn-c-c-346240/)

objorkum 07-24-2005 11:25 AM

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?

lowpro2k3 07-24-2005 12:27 PM

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

NCC-1701&NCC-1701-D 07-24-2005 12:31 PM

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! :)

exvor 07-24-2005 01:00 PM

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.

objorkum 07-24-2005 03:04 PM

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.

lowpro2k3 07-24-2005 03:33 PM

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.

Mara 07-24-2005 03:37 PM

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.

objorkum 07-25-2005 07:18 AM

Well, I don't have much experience. I do know PHP very well...

Do you have any beginners-books to recommend?

lowpro2k3 07-25-2005 01:27 PM

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

slzckboy 07-25-2005 03:01 PM

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.

chrism01 07-25-2005 08:35 PM

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.

enemorales 07-26-2005 01:32 AM

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!

craigs1987 07-26-2005 04:43 AM

I found Ivor Hortons book, Beginning C (Third Edition) very helpful. Though I moved on to his ANSI C++ rather than move to GTK+.

Nylex 07-26-2005 07:16 AM

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 :).

objorkum 07-30-2005 07:58 AM

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.


All times are GMT -5. The time now is 07:21 AM.