Options

Going from C++ to C

Master Of PuppetsMaster Of Puppets Member Posts: 1,210
Hi guys,

I want to learn C but I have no experience whatsoever in it. As one of my professors says - I'm some kind of a badass when it comes to C++ :D So that probably helps. At the university we started straight from C++ and I was never really interested in C. So my question is, has anyone made that transition? Any tips or things to look out for? I think it's going to be uncomfortable going from C++ to C but maybe it's not that bad. I think the best scenario is doing the opposite but too late for that now. Also, I would really appreciate if someone could recommend a good book that is suitable for the situation. Something not for a total beginner as I don't need to learn programming from the ground up.
Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.

Comments

  • Options
    NetworkVeteranNetworkVeteran Member Posts: 2,338 ■■■■■■■■□□
    C is still an extremely common and important language for embedded applications. Just remember, you don't have to write C code like an old-time C developer. The best code tends to follow the principles of C++ (such as OOP) while using the tool of the C language. I like "The C Programming Language" by K&R, assuming you already know C++ and basic programming concepts.
  • Options
    ptilsenptilsen Member Posts: 2,835 ■■■■■■■■■■
    I plan on learning both. I haven't touched either in years, but I had done a little bit of each in the past without any major issues.

    The real key is knowing imperative programming concepts and how to use them in the absence of object-oriented features. I operate in higher-level languages today that follow the same respective paradigms, and it's really not too bad. If all you've done is object-oriented, you will have a bit of a learning curve, but really, it's not so bad. I started with imperative/procedural and multi-paradigm languages and if anything, found them much easier to pick up than pure OOP, but I'm thinking there's a bit of unlearning to do when switching in either direction.

    As far as learning it, I'm not convinced there's any reason to go to anything but the original source, The C Programming Language, written by the language's creator. I did some fairly extensive searching on Amazon, and based on reviews and popularity, this is probably still the best book for the non-novice programmer, 25 years after being written. Edit: Looks like NetworkVeteran is on the same page on this one.
    Working B.S., Computer Science
    Complete: 55/120 credits SPAN 201, LIT 100, ETHS 200, AP Lang, MATH 120, WRIT 231, ICS 140, MATH 215, ECON 202, ECON 201, ICS 141, MATH 210, LING 111, ICS 240
    In progress: CLEP US GOV,
    Next up: MATH 211, ECON 352, ICS 340
  • Options
    Master Of PuppetsMaster Of Puppets Member Posts: 1,210
    Thanks guys. Looks like it really won't be an issue. I have done a lot of OOP which turns out to have never-ending benefits.
    Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.
  • Options
    sratakhinsratakhin Member Posts: 818
    C is just C++ without objects and classes. Simplified explanation but whatever :)
    Actually, C++ builds on C, so you know it already.
  • Options
    SlowhandSlowhand Mod Posts: 5,161 Mod
    You could always give yourself a refresher on what you already know about C, and probably a whole lot you don't: Learn Code The Hard Way -- Books And Courses To Learn To Code

    Free Microsoft Training: Microsoft Learn
    Free PowerShell Resources: Top PowerShell Blogs
    Free DevOps/Azure Resources: Visual Studio Dev Essentials

    Let it never be said that I didn't do the very least I could do.
  • Options
    paul78paul78 Member Posts: 3,016 ■■■■■■■■■■
    +1 for the K&R book. I cherish my first edition fondly.

    Thbbft! In my day, we didn't have fancy namespaces, objects, or classes. None of that silly templates, polymorphism and inheritance either. And I had to walk to work uphill both ways in the snow. icon_wink.gif
  • Options
    ptilsenptilsen Member Posts: 2,835 ■■■■■■■■■■
    paul78 wrote: »
    +1 for the K&R book. I cherish my first edition fondly.

    Thbbft! In my day, we didn't have fancy namespaces, objects, or classes. None of that silly templates, polymorphism and inheritance either. And I had to walk to work uphill both ways in the snow. icon_wink.gif
    Hey, IMO, these things don't make the language easier to learn, or even easier to use for simple programs. It's hard to appreciate a lot of aspects of OOP until you get into more complex applications.

    Edit: By the way, showing your age. :P The second edition was published the year I was born.
    Working B.S., Computer Science
    Complete: 55/120 credits SPAN 201, LIT 100, ETHS 200, AP Lang, MATH 120, WRIT 231, ICS 140, MATH 215, ECON 202, ECON 201, ICS 141, MATH 210, LING 111, ICS 240
    In progress: CLEP US GOV,
    Next up: MATH 211, ECON 352, ICS 340
  • Options
    paul78paul78 Member Posts: 3,016 ■■■■■■■■■■
    yeah - I'm old and bitter icon_lol.gif I learned C++ using Cfront. Those days of debugging C++ code translated into C left me forever traumatized.
  • Options
    TheShadowTheShadow Member Posts: 1,057 ■■■■■■□□□□
    paul78 wrote: »
    yeah - I'm old and bitter icon_lol.gif I learned C++ using Cfront. Those days of debugging C++ code translated into C left me forever traumatized.

    Yeah what he said. I also own a dog eared first edition and a nice second edition. After learning Simula, Cfront wasn't so bad.
    Who knows what evil lurks in the heart of technology?... The Shadow DO
Sign In or Register to comment.