Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

are there any tutorials to help a proficient c++ programmer learn c?

Tags:

c++

c

I became a professional programmer in the era of object oriented code, and have years of experience programming in C++. I often work on large projects that have years of legacy code in a mix of c++ and c. I feel less comfortable working on pure c parts of systems. From programming in C++ I understand all the c syntax, but there's a hole in my knowledge about how to organise a complex c program without objects, and what constitutes best practise for managing memory that I would like to fill. I learnt c++ after working as a java programmer, and think a bit more c would make me a better c++ programmer, and a bit less of a java translated into c++ programmer

like image 747
compound eye Avatar asked Aug 02 '09 23:08

compound eye


People also ask

How I can learn C programming on my own?

Get started with C. Official C documentation - Might be hard to follow and understand for beginners. Visit official C Programming documentation. Write a lot of C programming code - The only way you can learn programming is by writing a lot of code.

How long does it take to be proficient in C?

Within about 2 months to a year of your learning process, you should now be able to read C code without too much googling and get at least a basic sense of what the program is doing just by reading the code. You should also be able to write C code and know what to google when you forget the syntax.


2 Answers

In terms of organization, looking at the POSIX APIs, especially pthreads will give you a good idea of how to organize C code. The basic rules of good C project organization are:

  • Don't expose your structures. Use opaque types only.
  • Use the library and data type names as prefixes for function names.
  • Provide "create" and "destroy" functions for allocation/construction and destruction/deallocation.
  • Pass in the opaque type as the first parameter to functions operating on that type.
  • Implement the C APIs using either C or C++ (it's up to you). Obviously, use non-opaque types there.
like image 152
Michael Aaron Safyan Avatar answered Oct 16 '22 13:10

Michael Aaron Safyan


some google results:

C for C++ programmers

C for C++ programmers 2

like image 42
Gordon Gustafson Avatar answered Oct 16 '22 15:10

Gordon Gustafson