Want to relearn C, what book?

bob4432

Lifer
Sep 6, 2003
11,695
28
91
Title says it all, learned C probably 15 yrs ago and never got a chance to really use it, so, well, can not program in C. Had an old book but figured there are so many technology differences between then and now, with all the different platforms, etc. I may as relearn with a strong core from this century.

My goals for your suggestions:
- Relearn good core C programming principles. I have a feeling a lot of this will come back to me, but I would like to make sure I will be guided correctly.

- I use multiple platforms, so will be programming for PC and also iOS, Android and other embedded systems where I have designed the hardware and would like to write my own code for it.

Please advise,
Bob
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,282
3,904
75
C is old. For Android you use Java, not C. I'm not sure what apple people use these days.

For embedded you use C, which hasn't changed in many years, C++ which has only changed a little, or maybe Java.

Edit: Point is for C an old book should be fine.
 

Exophase

Diamond Member
Apr 19, 2012
4,439
9
81
C is old. For Android you use Java, not C. I'm not sure what apple people use these days.

For Android I use C (and assembly), although there is some inevitable Java glue code involved to call the NDK libraries.

Java on Android is just not sufficient for the performance requirements of my app.

Even if you don't have similar performance requirements using something like C/C++ means you get easier portability between Android and iOS. So while they're not at all the vendor preferred language for either platform they're a good lowest common denominator.

For embedded you use C, which hasn't changed in many years, C++ which has only changed a little, or maybe Java.

It's worth getting a primer on the C revisions made in 1999 (going to assume these weren't learned 15 years ago) and maybe the ones in 2011. Possibly also some compiler extensions.

I wouldn't bother with a book, a website is fine. Especially since you can get ones with interactive tutorials. Like this: http://www.learn-c.org/
 

sckyless

Junior Member
Sep 18, 2015
2
0
0
The C Programming Language 2nd Edition by Brian W. Kernighan & Dennis M. Ritchie

I first started learning programming with this book, then switched to iPhone development. This book added a great journey to my career.
 
Last edited:

postmortemIA

Diamond Member
Jul 11, 2006
7,721
40
91
Any book is a reference, C is learned through the practice.

Be advised that C-style programming is sword with two edges in object-oriented world. People that know C very well tend to not use or understand advantages of OO languages like C++.
 

bob4432

Lifer
Sep 6, 2003
11,695
28
91
Appreciate the info.

Any book is a reference, C is learned through the practice.

Be advised that C-style programming is sword with two edges in object-oriented world. People that know C very well tend to not use or understand advantages of OO languages like C++.
 

SteveGrabowski

Diamond Member
Oct 20, 2014
7,120
5,998
136
The C Programming Language 2nd Edition by Brian W. Kernighan & Dennis M. Ritchie

This. K&R is one of the best written programming books I have ever seen, the style they code in is beautiful, and the book is full of fun exercises. I love the last chapter when you implement your own malloc. I really love APUE2 also, but that's for C programming on UNIX.
 

bob4432

Lifer
Sep 6, 2003
11,695
28
91
One area I do have concerns is is for the smaller embedded items I am wanting to mess around with. Limited amounts of memory, direct hardware interaction, reading/writing to certain memory addresses, etc. I am assuming that I would just deal with the datasheets of the various components on that?
 

sao123

Lifer
May 27, 2002
12,648
201
106
Forget C.
Forget C++.
Learn C#.

It does practically everything and is far superior to Java.
Web? Check
Windows\Linux? Check
Mobile? Check
Embedded? Check
 

postmortemIA

Diamond Member
Jul 11, 2006
7,721
40
91
Nice troll, sao.

For embedded systems, might want to refresh yourself with posix standards use.
 

SOFTengCOMPelec

Platinum Member
May 9, 2013
2,417
75
91
One area I do have concerns is is for the smaller embedded items I am wanting to mess around with. Limited amounts of memory, direct hardware interaction, reading/writing to certain memory addresses, etc. I am assuming that I would just deal with the datasheets of the various components on that?

Best to learn C first, without embedded complexity. (my opinion).

Embedded is best/easiest with a compiler, tailored to the specific microcontroller. Then I/O definitions, peripheral sets, inlining and possibly drivers, will be already done for you. Along with in most/all cases, much internet help as well.

If you are completely free as to what the hardware is. I would suggest something like the raspberry PI (2). As it readily has operating systems (such as Linux), C compilers (GCC) and advice over the internet/books/etc on how to do it.

But yes, you can do it straight from the datasheets. In some cases, you would need inline/intrinsics assembly code (E.g. Disable interrupts), but tailored compilers, would hopefully have most of the stuff built in, in some fashion.

Example (Cpuid) in the PC world, from Intels website. I.e. Some stuff may have to be done via ASM. But ideally it will already be part of your compiler.

Code:
void cpuid (cpuid_t *info, unsigned int leaf, unsigned int subleaf)
31
{
32
    asm volatile("cpuid"
33
    : "=a" (info->eax), "=b" (info->ebx), "=c" (info->ecx), "=d" (info->edx)
34
    : "a" (leaf), "c" (subleaf)
35
    );
36
}
 
Last edited:

sao123

Lifer
May 27, 2002
12,648
201
106
Nice troll, sao.

For embedded systems, might want to refresh yourself with posix standards use.


Are you saying the .NET Micro Framework Architecture is insufficient for embedded development?

Native code is not the only acceptable approach to embedded projects nowadays.
 

Donanza

Member
Sep 13, 2015
41
0
66
Man, you sure have a very long time since you learned C language.
I would strongly suggest C Primer Plus book.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Are you saying the .NET Micro Framework Architecture is insufficient for embedded development?

Native code is not the only acceptable approach to embedded projects nowadays.

Writing an app for iOS, Android or Windows Phone is not embedded. You're targeting an operating system, not a piece of hardware.
 

bob4432

Lifer
Sep 6, 2003
11,695
28
91
Understand, but I am talking about designing the hardware (schematic->board design->have boards made->assemble board/s->flash code, etc) myself which I have done in the past but always had somebody else for the programming portion


Writing an app for iOS, Android or Windows Phone is not embedded. You're targeting an operating system, not a piece of hardware.
 

SOFTengCOMPelec

Platinum Member
May 9, 2013
2,417
75
91
Understand, but I am talking about designing the hardware (schematic->board design->have boards made->assemble board/s->flash code, etc) myself which I have done in the past but always had somebody else for the programming portion

Someone who has got many, many years of programming in C, embedded microcontroller experience (real time). Can with a degree of difficulty, tend to cope with what you have just described. Even if they have NOT got expensive test gear (such as emulators, logic analysers etc etc). Possibly even without the manufacturers development boards. Which can be amazingly cheap (like $75), in some cases.

But if someone who has never done (embedded real time C) programming on a microcontroller, with a reasonably complicated task to do/perform.

They will probably find the lack of pre-installed operating system (e.g. Linux), lack of diagnostic capabilities (No emulators etc), a really hard, uphill struggle, even to get it to do something quite simple. Let alone much more complicated things.

Peripherals tend to be difficult and fiddly/annoying to control in software, especially if you are completely inexperienced with them. There is a tendency if you get it wrong, at times, for the unit to just simply completely crash. Giving you no clue whatsoever, as to why, and what has gone wrong.

If you have got lots of time on your hands, and DON'T get frustrated easily, and really, really want to get your hands dirty, then do it.

It's much easier doing stuff like that in teams. Because you can split the work, and readily ask for advice from the many experienced engineers, who are working with you.

If you like. Try it for a few weeks and see how you get on. Without trying it, it can be difficult to put it into perspective, how hard and frustrating it can really be.

Analogy:
If there was someone who knew absolutely nothing about Electronics. Should they read a book on electronics for an hour or so. Then Design a 750 MHz 8 layer PCB, with complicated analogue/Digital circuitry, wave guides and create from scratch a large FPGA VHDL setup files ?

If it is a VERY simple, down to Earth task that your unit does, then things are not that bad.

EDIT: At times, I can be overly pessimistic and too negative. If others chime in with more confidence with this, please take that into account.
Since I'm not really sure exactly what you are trying to do here (overall, project wise), it is difficult to be accurate.
At the moment the project(s), could be anything, from a door bell unit, to a new control module for future space flights.
 
Last edited:
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |