Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the bad habits of C programmers starting to write C++? [closed]

Tags:

c++

c

People also ask

Should all programmers know C?

In the modern high level languages, the machine level details are hidden from the user, so in order to work with CPU cache, memory, network adapters, learning C programming is a must.

Do programmers still use C?

Despite the prevalence of higher-level languages, the C programming language continues to empower the world. There are plenty of reasons to believe that C programming will remain active for a long time. Here are some reasons that C is unbeatable, and almost mandatory, for certain applications.

Why is C difficult?

It is hard to learn because: It has complex syntax to support versatility. It is a permissive language—you can do everything that's technically possible, even if not logically right. It is best learned by someone who already has a foundation with C programming.

Is C programming hard for beginners?

C is more difficult to learn than JavaScript, but it's a valuable skill to have because most programming languages are actually implemented in C. This is because C is a “machine-level” language. So learning it will teach you how a computer works and will actually make learning new languages in the future easier.


Using raw pointers and resources instead of RAII objects.


  • using char* instead of std::string
  • using arrays instead of std::vector (or other containers)
  • not using other STL algorithms or libraries like boost where appropriate
  • abusing the preprocessor where constants, typedefs or templates would have been better
  • writing SESE-style (single-entry single exit) code

Declaring all the variables at the top of a function instead of as close as possible to where they are used.


Not using the STL, especially std::string,

and/or

using std::strings and reverting to old c string functions in tight corners.