If you're into robotics, Python, C, and C++ are all equally useful.
If that's the case, and you can learn all three, I would learn C first using this book. After that, I would move on to Python. After you feel comfortable with Python, learn modern C++.
If you can only learn one, go with Python.
C Programming Book
The C Programming Language
I quite like the book written by the developers of the language themselves. The C programming language.
K&R is the book for C, especially if you have prior programming experience.
If you want to learn C, you can follow along with Harvard's CS50 (the beginning in all about C). If you like it, you can do the entire course for free here.
Also, you should pick up the Bible of C Programming, KnR C Programming.
No, you don't... and no, it isn't. Stop listening to these literary nobodies and start listening to your book. I asked which one you're reading because it seems like the method you're using to learn isn't working for you (hence, you asked this question here, which people who read books wouldn't usually ask).
Look, I see this a lot. It would seem far too many people want to learn "the C programming language" purely by studying one rather common implementation... and so they end up learning a subset of the language which has subtle non-portable quirks that evolve a life of their own over time, perhaps becoming bugs or security issues.
C does not have pass-by-reference. I shouldn't need to point out that passing a reference type by value is still pass-by-value, because that should be written in your textbook somewhere. Take a look at this page if you'd like to know more about the difference between pass-by-reference and pass-by-value.
>By definition, pass by value means you are making a copy in memory of the actual parameter's value that is passed in, a copy of the contents of the actual parameter.
I predict a response similar to the following:
>... ok but C allows you to mimic pass-by-reference using pass-by-value ...
A turing complete language can mimic any other turing complete language, by definition. What can't happen is a reliable conversation in English if we don't agree upon the definitions for the words we use... and I quote, from the C11 standard, section 188.8.131.52
>In preparing for the call to a function, the arguments are evaluated, and each parameter is assigned the value of the corresponding argument
This squarely describes the assignment of a copy into a temporary or intermediate space ("the corresponding argument"), i.e. clearly pass-by-value...
Indeed, it's good to see I'm not the only one who strongly dislikes this website...
> Strings in C are the collection of characters. Strings are also known as an "Array of Characters".
That is utter nonsense! Quoting the C standard, you can see why:
> A string is a contiguous sequence of characters terminated by and including the first null character. The term multibyte string is sometimes used instead to emphasize special processing given to multibyte characters contained in the string or to avoid confusion with a wide string. A pointer to a string is a pointer to its initial (lowest addressed) character. The length of a string is the number of bytes preceding the null character and the value of a string is the sequence of the values of the contained characters, in order.
There are multiple contradictions in the implication your website creates. Let us look at them in order specified above:
>A string is a contiguous sequence of characters terminated by and including the first null character.
Where in your definition have you mentioned the terminating null character? Note that this implies a string doesn't necessarily span the entirety of the array and a string doesn't necessarily reside within an array at all.
>A pointer to a string is a pointer to its initial (lowest addressed) character.
If we interpret your website literally, then a pointer to a string is a pointer to an array of characters. The declaration of a pointer to an array of n characters named unusual_string_pointer looks like this:
This is unusual because it's very unlike the argument type accepted by our standard string functions. In addition to the implications I've mentioned earlier, from this most recent quote from the standard we can tell a string might begin mid-way through an array.
>The length of a string is the number of bytes preceding the null character and the value of a string is the sequence of the values of the contained characters, in order.
It's extremely common for newcomers to categorically confuse the concepts of strings and arrays, such that they believe strlen(string_in_array) would be sizeof string_in_array - 1. That is not necessarily the case, as this quote shows, yet your website does nothing to guide beginners past this common hurdle.
sizeof string_in_array - 1
Moving on to some other quotes within your page here...
>Strings in C is a one-dimensional array.
It is trivial to construct a string that isn't stored within an array. With the caveat that the only safe string (that I can think of) to do this with is an empty string, and that you'll probably want to use the &address-of operator to do this, I'll leave this to you as an exercise. The key take-home point here is strings are (typically) stored in arrays, but aren't the arrays. You could say that prime numbers are (typically) stored in int, but that's not necessarily always the case.
>Strings in C are ended by the "NULL ('\0') character.
>Strings are written in double quotes ("Programming") while the character is written inside a single quote ('A').
I wonder why you would assume the position of a teacher whilst confusing string literals for strings like this. Tell me, why isn't "Programming" ended by the "NULL ('\0') character in this text? To me it seems like you have two definitions merged into one, and they're contradicting each other.
I would also like to add that one example of a string (using the formal definition from 7.1.1p1 above) can be written using a character literal like so: '\0' (this is a hint for your exercise). A pointer to that string (also complying with the definition) can be written, without a declaration... and the length of that string (see 7.1.1p1 for this definition) can be written... all without declaring a single variable.
>A string literal need not be a string (see 7.1.1), because a null character may be embedded in it by a \0 escape sequence.
As you can see from footnote 78, an attempt to place a \0 terminating character into a string literal is likely to cause a string literal that isn't a string. Furthermore, if we use string literals as initialisers for arrays that aren't large enough to store the terminating byte, the string literal won't be treated like a string, for example: char fubar = "fubar"; // not a string.
char fubar = "fubar"; // not a string
Further common confusions appear in reality with our students, such that newcomers tend to think an array of characters is automatically a string and thus automatically contains a terminating null character... more utter nonsense which your website does nothing to quench... and to be clear on this, I expect more from an educator and was shocked to find you work at a university, teaching programming! This was the point at which I decided to start reporting you for misleading people (and plagiarism). You need to go back to university, as a student, and study C properly (without cheating on your exams).
To be clear on this, if you're going to use the writings of other people (like myself), you need to properly cite those writings. We've been down this road before; I threatened you with DMCA takedown, remember? Frankly, you disgust me. Our educators should know better... to think I am unemployed on a disability pension while you are employed in my dream position. You disgust me!
Even despite earlier making the erroneous statement that Strings are also known as an "Array of Characters", you go on to say...
> In C programming, strings are not used as a data type (like char, float, double, int etc.).
Don't you realise "Array of Characters" is a data type? You have mixed this last small ounce of truth that this page contains in gallons of utter rubbish, as demonstrated by the very next statement you make:
> Strings are declared like an array if you do not know what the arrays are? Then, first, you should read the arrays.
You're a hypocrite. If you don't know what constitutes C, then, prior to assuming the role of an I.T. professors assistant, you should read a book about C (and do the exercises, as you would expect of your students).
I'm not going to bother correcting all of your errors. It'd be less wasteful of my time to simply write my own textbook, and to be clear on that matter, there's nothing wrong with K&R2E. Your website exists without a purpose, and lies to people. What you should do, to be honest to your students and to the founding forefathers of the language, is redirect your entire domain to the Amazon page for K&R2E. Make an affiliate link, if you like, so that you get commissions on the sales... at least this way your students will learn the *actual** programming language, as opposed to your retarded imagination of it*.
K&R has the reputation it has because they did an excellent job of balancing between "experienced programmers can use this as a reference" and "newbie programmers can use this as a starting point. Let me clarify: K&R will not make you a better programmer, but it is an excellent example of what industry professionals would consider to be a good piece of technical documentation.
If you're going to ever work with APIs or large amounts of technical documentation about software, this book will mirror the experience you get reading "good docs". In short, learning C from this books does an excellent job of showing you how much you'll have to figure out yourself and what information you should be expected to be given to you when working in the industry.
I found it much easier to learn C first and then C++
BTW I don't use C++ anymore, just python and BASH.
Read K&R C and work through the examples.
C Programming Language, 2nd Edition https://www.amazon.com/dp/0131103628/ref=cm_sw_r_cp_apa_i_KsHRCbMHMDBX8
This is your new bible:
I haven't read either of those, but I did enjoy and find a lot of value in K&R and 21st Century C.
Since Objective C is an expansion of C, I suggest the C 'bible' from Kernichan and Ritchie.
K & R. [Kernighan & Ritchie]
You would probably benefit from a systems manual, on top of a general syntax book like K&R.
this is not based on any experience, just some research I did on my own. Unfortunately most C programming knowledge is locked up in textbooks or in reference documents. There isn't a ton of walkthrough style manuals for the language, despite how old it is.
C and Python are both used lots, and are good choices. C++ is beautiful and difficult, and there is a shortage of excellent material to learn from.
If you go with C, which is fast and great and, on its own, relatively easy to learn, the following book is likely the best way to learn it. It is known affectionately as the 'K&R Bible'.
If you go with Python, most resources will teach you a decent chunk decently well. You'll likely have trouble moving to intermediate complexity programming, but will be able to find guidance when you get to it.
Good luck and have a great day!
It's very, very worthwhile if you're learning C. A bit dry, but very concise and easy to understand.
Just read The C Programming Language and write code. If you're new to it then you need first-hand experience so you can learn what the subtleties are. Just reading a list won't help a huge amount.