Jump to content

Advice for learning C\C++ efficiently


The Grinch

Recommended Posts

As the title implies: I'd like to look into learning to code in C (Mostly due to how it seem interesting and because it could be of good use later), but due to mental health issues (Depression and anxiety) I find myself lost as to how to properly tackle this language. What would generally be the easiest way to get around it?  And if you can relate to this situation, what did you do?

Link to comment
Share on other sites

Hey there,

So I've been learning C for the past year now as a part of a special program and I'll give you some tips right now!

 

1. The tools: To work with C you need a fitting working environment so for that I suggest you to download right now Notepad++ and for the compiler of the code download minU GCC.

 

2. To learn the language I'll suggest you two very specific tools. So the first one will be a website called Hackforums which has a very in depth guide about C.

The other one will be Lynda guides, that I am sure anyone can find and download via torrents.

 

3. When you finish a specific part of learning (for example after you finish learning the use of ints, chars, floats printf i.e) search the web for questions in that part, try to practice as much as you can, I assure you that it's the only way to get really experienced and good at the language.

 

4. C can sometime be very frustrating due to errors and simple mistakes that the compiler can't find because compiler is part of the computer and the computer is dumb, hence you should always take a deep breath before you start to debug and focus a lot on enhancing your code, clean writing and sticking to the conventions.

 

5. Have fun! Learning something you'd like to learn and liking the subject is the best thing you can do to yourself, if you enjoy something do it more often and in this specific subject I'm sure it will pay off.

 

Other then that I wish you luck and as I said have fun!

Link to comment
Share on other sites

1 hour ago, AcedusBloodOath said:

Hey there,

So I've been learning C for the past year now as a part of a special program and I'll give you some tips right now!

 

1. The tools: To work with C you need a fitting working environment so for that I suggest you to download right now Notepad++ and for the compiler of the code download minU GCC.

 

2. To learn the language I'll suggest you two very specific tools. So the first one will be a website called Hackforums which has a very in depth guide about C.

The other one will be Lynda guides, that I am sure anyone can find and download via torrents.

 

3. When you finish a specific part of learning (for example after you finish learning the use of ints, chars, floats printf i.e) search the web for questions in that part, try to practice as much as you can, I assure you that it's the only way to get really experienced and good at the language.

 

4. C can sometime be very frustrating due to errors and simple mistakes that the compiler can't find because compiler is part of the computer and the computer is dumb, hence you should always take a deep breath before you start to debug and focus a lot on enhancing your code, clean writing and sticking to the conventions.

 

5. Have fun! Learning something you'd like to learn and liking the subject is the best thing you can do to yourself, if you enjoy something do it more often and in this specific subject I'm sure it will pay off.

 

Other then that I wish you luck and as I said have fun!

Thank you so much! I'll start with these and see how it goes :)

Link to comment
Share on other sites

Well, if you're using Windows, I'd recommend CodeBlocks. Personally I'd recommend a Linux environment (like Ubuntu) for C programming since the compiler's already included there (and it gets updated as you update Ubuntu). 

 

As for references, you could look up tutorialspoint for C or http://www.cplusplus.com (which I think it's old, but most of the functions are still used).

Link to comment
Share on other sites

  • 2 weeks later...

for good programming in general getting used to a good environment is the best advice i can give. personally, i use vim because of the vast amount of customization it has and how strong it can be at helping you code efficiently once you get the hang of it. the huge huge huge documentation on c and c++ will help you along the way and understanding what the docs are talking about will help you direct yourself when using weird niche libraries. other than that just practice practice practice and it will come to you eventually. try to understand pointers (who the fuck am i kidding, no one understands pointers) and memory allocation if you're wanting to focus on C.

 

other than that i have 10 general programming tips that ive learned over the course of a few years:

1. dont misuse assignment (=) with a test for equality (==)

2. using namespace std; is your friend for most simple programming. understand what it means, however.

3. only use global variables for communicating between functions

4. use local variables inside for loops

5. use ++ and --

6. learn to comment code as you go and also, time permitting, write pseudo-code

7. gets() is bad bad bad

8. git is your best friend. it's daunting at first but it's super simple to use

9. always write if statements with braces

10. INDENT

Link to comment
Share on other sites

On 23/2/2017 at 5:51 AM, Jelly said:

who the fuck am i kidding, no one understands pointers

Bullshit. Grok pointers or you're going nowhere

 

On 23/2/2017 at 5:51 AM, Jelly said:

1. dont misuse assignment (=) with a test for equality (==)

This is true. It happens to beginners all the time

 

On 23/2/2017 at 5:51 AM, Jelly said:

2. using namespace std; is your friend for most simple programming. understand what it means, however.

Just don't. Using namespaces is bad. Just think that there were some interest in omitting namespaces, then namespaces would have never existed in the first place. Knowing that you are using a feature form the stl just by looking at it is useful in my opinion.

 

On 23/2/2017 at 5:51 AM, Jelly said:

3. only use global variables for communicating between functions

This is true. Try to avoid global state as much as possible and encapsulate it always. In C, never use extern and use static global variables. In C++, use static class variables and make them private. Never use global variables directly except in the module they belong to.

 

On 23/2/2017 at 5:51 AM, Jelly said:

4. use local variables inside for loops

Use local variables in general. Prefer scoped lifetime whenever it's possible.

 

On 23/2/2017 at 5:51 AM, Jelly said:

5. use ++ and --

True.

 

On 23/2/2017 at 5:51 AM, Jelly said:

6. learn to comment code as you go and also, time permitting, write pseudo-code

This is crucial.

 

On 23/2/2017 at 5:51 AM, Jelly said:

7. gets() is bad bad bad

stdin is in general pretty awful. Try to avoid console input.

 

On 23/2/2017 at 5:51 AM, Jelly said:

8. git is your best friend. it's daunting at first but it's super simple to use

Git is great. If it's too complicated, mercurial can be an easier option for a beginner. Use sourcetree to make using them easier.

 

On 23/2/2017 at 5:51 AM, Jelly said:

9. always write if statements with braces

Nonesense. There's nothing wrong with 

if (a)

    b();

Alexandrescu's style of

if (a) b(); can be detrimental if you're using an IDE and can be quite unreadable too, but there's nothing wrong with not using braces in an if statement.

 

On 23/2/2017 at 5:51 AM, Jelly said:

10. INDENT

True.

 

As a final advice, use http://en.cppreference.com/w/ for C and C++ language reference over any other page.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...