Jump to content

Quite simply I want/need to learn how to code in C. And I am wondering a few things,

A) is there any guides etc. which can be used in order to start learning which are free, as me no money

B) any hints tips or tricks I should know about before I start which will be helpful to know

C) is there any other helpful information I should know before I start.

 

Thanks in advance

The owner of "too many" computers, called

The Lord of all Toasters (1920X 1080ti 32GB)

The Toasted Controller (i5 4670, R9 380, 24GB)

The Semi Portable Toastie machine (i7 3612QM (was an i3) intel HD 4000 16GB)'

Bread and Butter Pudding (i7 7700HQ, 1050ti, 16GB)

Pinoutbutter Sandwhich (raspberry pi 3 B)

The Portable Slice of Bread (N270, HAHAHA, 2GB)

Muffinator (C2D E6600, Geforce 8400, 6GB, 8X2TB HDD)

Toastbuster (WIP, should be cool)

loaf and let dough (A printer that doesn't print black ink)

The Cheese Toastie (C2D (of some sort), GTX 760, 3GB, win XP gaming machine)

The Toaster (C2D, intel HD, 4GB, 2X1TB NAS)

Matter of Loaf and death (some old shitty AMD laptop)

windybread (4X E5470, intel HD, 32GB ECC) (use coming soon, maybe)

And more, several more

Link to comment
https://linustechtips.com/topic/792122-tips-hints-and-help-about-c/
Share on other sites

Link to post
Share on other sites

You should probably get this book: https://www.amazon.com/Programming-Language-Brian-W-Kernighan/dp/0131103628

 

To get started though, I strongly recommend your development environment be Linux and working through the terminal. You can use a VM like Oracle's VirtualBox and some distro (Lubuntu or Linux Mint is my recommendation). Granted you could also install an IDE as well. I think Microsoft has a free version of Visual Studio that can do C.

 

Also keep in mind C is a  rather low level language. You should also get a basic idea of how computers work on the hardware level.

Link to post
Share on other sites

Note that the current C11 standard differs from what Brian W. Kernighan considered to be C.

 

4 hours ago, M.Yurizaki said:

To get started though, I strongly recommend your development environment be Linux and working through the terminal.

 

This is a horrible advice. Learning a language AND an operating system will probably fail. Also, Windows is actually fine for C development!

So ...

 

4 hours ago, M.Yurizaki said:

You can use a VM like Oracle's VirtualBox and some distro (Lubuntu or Linux Mint is my recommendation).

 

... my recommendation is: Don't.

 

4 hours ago, M.Yurizaki said:

Granted you could also install an IDE as well.

 

http://www.smorgasbordet.com/pellesc/

 

4 hours ago, M.Yurizaki said:

I think Microsoft has a free version of Visual Studio that can do C.

 

Yes, but Microsoft has its own approach to newer C features like threads as they focus on C#, C++ and Visual Basic.

The Windows "libc" does not support some of the "new" C11 features (yet?).

 

However, when on Windows, you can perfectly use the WinAPI equivalents (Win32 threads et cetera).

Write in C.

Link to post
Share on other sites

K&R C is the "classic" C book. That being said, I despised it when I first read (my first real programming class was in Java which I took my first semester of college; C and C++ were taken my second semester). I still dislike it. The reason why I dislike it is because the book is just outdated in its examples. The book presumes you know an older language (keep in mind that this book was last revised in the late 1980s) and tries to relate to those languages. The problem is that if you're learning C today, you almost certainly don't know those languages. I personally thought that reading the tutorials point guide on C to be far more useful in that they use plain English and practical examples that don't presume you have prior programming knowledge (in an obsolete language). In retrospect, I think the best approach is still to do the tutorials point tutorial, practice a lot, and then follow up with a light skimming of the K&R C book. 

 

https://www.tutorialspoint.com/cprogramming/

 

If you have a Mac, use that. If you have Windows, you _may_ be able to get away using WSL. However, I'd suggest you virtualize a Linux distro or dual boot it. I'd also suggest you use clang rather than gcc since, in my experience, clang produces far more useful error messages. 

Link to post
Share on other sites

7 hours ago, kevindong0 said:

K&R C is the "classic" C book. That being said, I despised it when I first read (my first real programming class was in Java which I took my first semester of college; C and C++ were taken my second semester). I still dislike it. The reason why I dislike it is because the book is just outdated in its examples. The book presumes you know an older language (keep in mind that this book was last revised in the late 1980s) and tries to relate to those languages. The problem is that if you're learning C today, you almost certainly don't know those languages. I personally thought that reading the tutorials point guide on C to be far more useful in that they use plain English and practical examples that don't presume you have prior programming knowledge (in an obsolete language). In retrospect, I think the best approach is still to do the tutorials point tutorial, practice a lot, and then follow up with a light skimming of the K&R C book. 

 

https://www.tutorialspoint.com/cprogramming/

 

If you have a Mac, use that. If you have Windows, you _may_ be able to get away using WSL. However, I'd suggest you virtualize a Linux distro or dual boot it. I'd also suggest you use clang rather than gcc since, in my experience, clang produces far more useful error messages. 

aye  I'm using volume 2 of that book to be honest it anit to bad, it's certainly dated e.g. you used to be able just to write

main()

{

-insert code stuff here-

}

 

but now if you do that it complains (it still works though) and you need to write

int main(void)

{

-insert code stuff here-

}

 

which is fine and all, but I would rather have the original, for two reasons one that how the book writes it, two it's much quicker to type out

 

as for what programme I'm using pelles C it's meh, but it works reasonably well at the moment. But yea syntax was a bitch (it took me 15 mins to realise I had a missing comma which meant the code wouldn't run)

The owner of "too many" computers, called

The Lord of all Toasters (1920X 1080ti 32GB)

The Toasted Controller (i5 4670, R9 380, 24GB)

The Semi Portable Toastie machine (i7 3612QM (was an i3) intel HD 4000 16GB)'

Bread and Butter Pudding (i7 7700HQ, 1050ti, 16GB)

Pinoutbutter Sandwhich (raspberry pi 3 B)

The Portable Slice of Bread (N270, HAHAHA, 2GB)

Muffinator (C2D E6600, Geforce 8400, 6GB, 8X2TB HDD)

Toastbuster (WIP, should be cool)

loaf and let dough (A printer that doesn't print black ink)

The Cheese Toastie (C2D (of some sort), GTX 760, 3GB, win XP gaming machine)

The Toaster (C2D, intel HD, 4GB, 2X1TB NAS)

Matter of Loaf and death (some old shitty AMD laptop)

windybread (4X E5470, intel HD, 32GB ECC) (use coming soon, maybe)

And more, several more

Link to post
Share on other sites

I mean, do you want to learn C the easy way or the hard way? The easy way is well, easier. But the hard way will teach you far more about the intricacies of C via trial by fire. 

 

The easy way is to install an IDE such as CLion. You'll find the in-line checking of syntax and basic logical errors to be very useful. The hard way is to use a plain text editor with some syntax highlighting and autoindent, but nothing else. 

Link to post
Share on other sites

55 minutes ago, kevindong0 said:

I mean, do you want to learn C the easy way or the hard way? The easy way is well, easier. But the hard way will teach you far more about the intricacies of C via trial by fire. 

 

The easy way is to install an IDE such as CLion. You'll find the in-line checking of syntax and basic logical errors to be very useful. The hard way is to use a plain text editor with some syntax highlighting and autoindent, but nothing else. 

I need to learn a large amount of C in 10 days, so I'll do easy as I can power through it faster, probably

The owner of "too many" computers, called

The Lord of all Toasters (1920X 1080ti 32GB)

The Toasted Controller (i5 4670, R9 380, 24GB)

The Semi Portable Toastie machine (i7 3612QM (was an i3) intel HD 4000 16GB)'

Bread and Butter Pudding (i7 7700HQ, 1050ti, 16GB)

Pinoutbutter Sandwhich (raspberry pi 3 B)

The Portable Slice of Bread (N270, HAHAHA, 2GB)

Muffinator (C2D E6600, Geforce 8400, 6GB, 8X2TB HDD)

Toastbuster (WIP, should be cool)

loaf and let dough (A printer that doesn't print black ink)

The Cheese Toastie (C2D (of some sort), GTX 760, 3GB, win XP gaming machine)

The Toaster (C2D, intel HD, 4GB, 2X1TB NAS)

Matter of Loaf and death (some old shitty AMD laptop)

windybread (4X E5470, intel HD, 32GB ECC) (use coming soon, maybe)

And more, several more

Link to post
Share on other sites

I think one of the best ways to learn C, if not practice it, is to program for a microcontroller, like a Cortex M4 or Arduino. But not a Raspberry Pi.

 

My favorite "sanity check" projects are to get an LED to turn on/off from one of the buttons (most microcontroller kits come with at least one user button) and get a UART going (but this requires a serial terminal program)

 

You get to touch hardware on a lower level, which is what C is best at doing, and you can do something fun. It won't teach you things like file I/O or maybe even standard I/O (like using printf or scanf), but you can crank out the fundamentals of programming none the less

Link to post
Share on other sites

Also, even if the examples in the K & R C book are outdated, it still teaches you some fundamentals to get you going.

 

Though admittedly, yes, it's more of a reference or text book than a tutorial.

Link to post
Share on other sites

2 minutes ago, M.Yurizaki said:

I think one of the best ways to learn C, if not practice it, is to program for a microcontroller, like a Cortex M4 or Arduino. But not a Raspberry Pi.

 

My favorite "sanity check" projects are to get an LED to turn on/off from one of the buttons (most microcontroller kits come with at least one user button) and get a UART going (but this requires a serial terminal program)

 

You get to touch hardware on a lower level, which is what C is best at doing, and you can do something fun. It won't teach you things like file I/O or maybe even standard I/O (like using printf or scanf), but you can crank out the fundamentals of programming none the less

I have an arduino and have coded it, but it was never more advanced than basic boolean, motor control and some basic logic (e.g. NOT, AND, NAND, OR, etc.)

The owner of "too many" computers, called

The Lord of all Toasters (1920X 1080ti 32GB)

The Toasted Controller (i5 4670, R9 380, 24GB)

The Semi Portable Toastie machine (i7 3612QM (was an i3) intel HD 4000 16GB)'

Bread and Butter Pudding (i7 7700HQ, 1050ti, 16GB)

Pinoutbutter Sandwhich (raspberry pi 3 B)

The Portable Slice of Bread (N270, HAHAHA, 2GB)

Muffinator (C2D E6600, Geforce 8400, 6GB, 8X2TB HDD)

Toastbuster (WIP, should be cool)

loaf and let dough (A printer that doesn't print black ink)

The Cheese Toastie (C2D (of some sort), GTX 760, 3GB, win XP gaming machine)

The Toaster (C2D, intel HD, 4GB, 2X1TB NAS)

Matter of Loaf and death (some old shitty AMD laptop)

windybread (4X E5470, intel HD, 32GB ECC) (use coming soon, maybe)

And more, several more

Link to post
Share on other sites

8 hours ago, M.Yurizaki said:

I think one of the best ways to learn C, if not practice it, is to program for a microcontroller, like a Cortex M4 or Arduino. But not a Raspberry Pi.

 

My favorite "sanity check" projects are to get an LED to turn on/off from one of the buttons (most microcontroller kits come with at least one user button) and get a UART going (but this requires a serial terminal program)

 

You get to touch hardware on a lower level, which is what C is best at doing, and you can do something fun. It won't teach you things like file I/O or maybe even standard I/O (like using printf or scanf), but you can crank out the fundamentals of programming none the less

Could you expand upon how programming a microcontroller would help for non-embedded applications? I can't really think of any ways it would help aside from learning the bare minimum of control flow. 

Link to post
Share on other sites

12 minutes ago, kevindong0 said:

Could you expand upon how programming a microcontroller would help for non-embedded applications? I can't really think of any ways it would help aside from learning the bare minimum of control flow. 

Being able to get down to the bare metal I feel brings a better appreciation and understanding of how computers and programming work, which can carry over to any language. And you can do it without an OS looking over your shoulder telling you what you can and cannot do. You can still learn things like interrupts, timers, basic I/O. And besides that, while C can be used to create application software, it's more suited for system software.

 

But at the end of the day, I advocate for anyone who is serious about software development to learn how a computer works. The language is just there to help learn that.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×