Shop OBEX P1 Docs P2 Docs Learn Events
I've always wanted to learn C... — Parallax Forums

I've always wanted to learn C...

Jorge PJorge P Posts: 385
edited 2011-11-21 09:19 in Propeller 1
The main confusion for me is are the colons " : ", " :: ", stars " * ", " ** ", and "->". For the most part I can follow c program structures but get lost with structs, when to use them, etc... In code, I have only seen "->" in cpp programs, or at least the ones I have obtained/compared.

Will there be a book for Propeller GCC, and C programming in general, eventually, that will show a newbie to c programming how it all works? Hopefully without the lengthy helloWorld chapter, I would like something more like the Jabberwok example in Java. I have read the beginning 1/3 of at least 3 different c programming books over the years and they always lose my attention the first couple of chapters. I would prefer something more like an *nix info-manual but in PDF or hardcopy. I would like to see explanations of things like if, else, case, while, etc.. kept to a minimum since they are similar in most languages including basic.

Is this just me, or do others feel the same about the modern programming books? Am I stuck with C# for life?

I will be watching this section of the forums for the first non alpha/beta release. I'd like to finally give c a whirl after I try to forget C#. I want to learn as if I didn't know any programming at all, to a certain extent.

Thanks to the developers for taking on the lengthy task of porting and testing.

Comments

  • LeonLeon Posts: 7,620
    edited 2011-11-20 07:18
    Just get a copy of The C Programming Language. It has everything you need.
  • TorTor Posts: 2,010
    edited 2011-11-20 10:01
    Yep, get the book (the printed one - it'll work better than any on-screen version), but get the ANSI one.

    Those colons won't bother you much in C proper, except for some special cases of shorthand which can safely be ignored for the time being. The thing about asterisks and arrows (* and ->) is all about learning to understand pointers, i.e. addresses. What the asterisk does is to refer to the value that the pointer (the address) is pointing to, and the arrow refers to an item of a struct (a record), just like a period ('.') does - the difference is that if an arrow is used then what you have is a pointer to the record, not the record itself. So, if you define a record (a struct) with members, then send the struct to a function the function can access the members by '.' if you pass the struct itself. If you passed the address to the struct (by prefixing it with '&') then the function must access its members by '->'.

    -Tor
  • Jorge PJorge P Posts: 385
    edited 2011-11-21 01:29
    @Tor
    thanks for the explanation, the c books usually take several chapters to explain that.

    @Leon or Tor
    Is the book you are referring to this one by "Prentice Hall, Inc." http://cm.bell-labs.com/cm/cs/cbook/ ? I had purchased other books on c programming, "Learn C and C++" and "C for Dummies", but never this one.
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2011-11-21 01:42
    That's the book, also known as Kernighan & Ritchie or K&R for the authors' last names. You might also want to look at C in a Nutshell, published by O'Reilly.
  • Daniel HarrisDaniel Harris Posts: 207
    edited 2011-11-21 09:19
    Hi Jorge,

    I can't say for sure because Parallax is just now beginning to explore the possibilities of C with the Propeller, but I'd be willing to bet that the Education department at Parallax recognizes the need for a C/C++ book. However, they would need the tool to be completed before they could really start writing. For now, other C/C++ books would the way to go to teach yourself.

    By the way, if memory serves, the "->" in C dereferences the pointer to a structure and access the named variable/object within the structure. Something like that...

    Found this:
    foo->bar is equivalent to (*foo).bar, i.e. it gets the member called bar from the struct that foo points to.

    From http://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c
Sign In or Register to comment.