Any good reference material for learning C/C++

tabswtc

Junior Member
May 17, 2012
1
0
0
Hello, i am a EE student. We have been taught java and i know it quite good. I have been using Swing/AWT and recently java FX for realizing GUI.

Soon i will be starting my thesis, but i have recently realized the importance of C++ considering it's use in production environment, so i am really getting inclined to learning it.

For this reason i want to know could you suggest me some suitable resources from where i should start considering i have already idea about java. Should i start first with C and then move on to C++, or should i directly start with C++.

I found a book about C, which claims about "learn C in 21 days", im thinking about giving it a try and after 1 month switch to C++, and spend another couple of months on C++. I only have 3 months time, before i will be graduating, can you please suggest me some resources which i should start with.

Thank you,

PS: I need to get a basic gist of the langauge, i know 2-3 months is no way near to learn a anything completely.
 
Last edited:

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Should i start first with C and then move on to C++, or should i directly start with C++.

It's good to have this debate at least once per month :). In my opinion just learn C++. There's not much benefit in focusing exclusively on C other than in some specific scenarios... which as an EE, come to think of it, you're probably more likely to encounter. Still, I would begin with C++.
 

uclabachelor

Senior member
Nov 9, 2009
448
0
71
Hello, i am a EE student. We have been taught java and i know it quite good. I have been using Swing/AWT and recently java FX for realizing GUI.

Soon i will be starting my thesis, but i have recently realized the importance of C++ considering it's use in production environment, so i am really getting inclined to learning it.

For this reason i want to know could you suggest me some suitable resources from where i should start considering i have already idea about java. Should i start first with C and then move on to C++, or should i directly start with C++.

I found a book about C, which claims about "learn C in 21 days", im thinking about giving it a try and after 1 month switch to C++, and spend another couple of months on C++. I only have 3 months time, before i will be graduating, can you please suggest me some resources which i should start with.

Thank you,

PS: I need to get a basic gist of the langauge, i know 2-3 months is no way near to learn a anything completely.

An option is to get into embedded mcu kits and start looking at and/or writing code. Most of the kits are in C or C++ and since you already know EE, understanding the hardware aspect of the mcu dev boards will be a piece of cake.
 

Absolution75

Senior member
Dec 3, 2007
983
3
81
imo learning c before c++ is detremental to the process. You may pick up bad habbits along the way or get confused on the best practices of each language.

Any C++ book will teach you everything anyway.
 

Colt45

Lifer
Apr 18, 2001
19,720
1
0
I'd say learn C first, K&R book is good.

But I can't really C++, so depends what you want to do. For the most part all I do is embedded and low level stuff, or small terminal programs, so C is great for this sort of thing. GUI fun, somewhat less so.

Seems pretty odd to me that EE students would be taught java and not C... Guess you guys aren't working on anything embedded huh. :awe:

If you ever plan on working with embedded stuff, either bare metal or linux, which seems like a sure thing for an EE these days - you'd better learn C.
 
Last edited:

irishScott

Lifer
Oct 10, 2006
21,562
3
0
Learn C++. If you know C++, you know or can easily pick up 90% of C. I got all my instruction via college/high school courses so I can't really reccomend books.
 

irishScott

Lifer
Oct 10, 2006
21,562
3
0
I'd say learn C first, K&R book is good.

But I can't really C++, so depends what you want to do. For the most part all I do is embedded and low level stuff, or small terminal programs, so C is great for this sort of thing. GUI fun, somewhat less so.

Seems pretty odd to me that EE students would be taught java and not C... Guess you guys aren't working on anything embedded huh. :awe:

If you ever plan on working with embedded stuff, either bare metal or linux, which seems like a sure thing for an EE these days - you'd better learn C.

We have something similar at my Univeristy, the issue is Computer Science and Computer/Electrical Engineering being separate departements. The CS department wants to emphasize algorithms and theory, while the ECE department wants more focus on resource management. So the intro-level computer science courses are almost all python and java now. Only hit c++ when learning about data structures. Sucks for a lot of students who come into data structres and have to take a crash course in pointers, they just don't know the language. Thankfully I came up before they changed the program around (before it went matlab -> c++). My engineering courses use C, but on a rather basic level that doesn't really focus on the language so much as embedded applications.
 

Cogman

Lifer
Sep 19, 2000
10,286
145
106
Learn C++. If you know C++, you know or can easily pick up 90% of C. I got all my instruction via college/high school courses so I can't really reccomend books.

90%? More like 99%. C and C++ are REALLY compatible. There are very few parts of C that are totally incompatible with C++ and those parts are easy enough to parse once you have a working knowledge of C++.

In the end, learning the language really doesn't matter. What is important is being able to structure code. Almost any language can be made readable (I draw the line at the likes of BrainFuck)
 

Cogman

Lifer
Sep 19, 2000
10,286
145
106
It's good to have this debate at least once per month :). In my opinion just learn C++. There's not much benefit in focusing exclusively on C other than in some specific scenarios... which as an EE, come to think of it, you're probably more likely to encounter. Still, I would begin with C++.

Meh, there aren't a whole lot of C++ gotchas. The only things that come to mind is the nature of templates to clone code, how class pass a WORD length invisible "this" pointer or how pass by reference results in a magic WORD length pointer being created.

Those things aren't really that big of an issue in the embedded environment. (Though, I guess the C++ name mangling scheme might pose more of a challenge for debugging).
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Meh, there aren't a whole lot of C++ gotchas. The only things that come to mind is the nature of templates to clone code, how class pass a WORD length invisible "this" pointer or how pass by reference results in a magic WORD length pointer being created.

Those things aren't really that big of an issue in the embedded environment. (Though, I guess the C++ name mangling scheme might pose more of a challenge for debugging).

It's been so long since I paid attention to embedded stuff that I don't really know what the constraints are anymore. I know that back in the day none of my friends doing embedded code would use C++ because of the overhead of the this pointer and the additional indirection of the virtual function table. Or at least those are the reasons I recall them mentioning.
 

LumbergTech

Diamond Member
Sep 15, 2005
3,622
1
0
It depends what you want to do. It is helpful to know old school C style stuff because you can get stuck working with it and if you only focus on the higher level C++ stuff that is much easier you may be in for a bit of a struggle for a while.
 

piasabird

Lifer
Feb 6, 2002
17,168
60
91
A lot depends on what you want to do. C is pretty basic. However, if you know Java it is similar to C++ or pascal. The Dietel books were kind of informative. You could start with learn C++ in 24 hours and then move on to some more complex book with examples of building classes and objects. The best kind of book is one with lots of samele programs. You learn by coding. There is something about typing out the code and compiling that better explains what it is doing.