Conclusion

You have covered a lot of ground — from printf format specifiers to file descriptors to pointer ownership. Here are the key takeaways:

  • C and C++ are different languages. Modern C++ has evolved far from C. Knowing one does not mean you automatically know the other.
  • printf and scanf replace iostream. Format specifiers must match argument types. scanf needs & for scalar variables.
  • C types are explicit. No auto, no std::string, no classes. You have basic types, typedef, arrays, and struct.
  • C shares most operators with C++ but there is no operator overloading, << and >> are strictly bitwise, and boolean results are plain int.
  • Control flow is nearly identical to C++ except there are no range-based for loops and goto is an accepted idiom for cleanup.
  • Pointers hold memory addresses. Use & to get an address, * to follow one, and -> to access struct fields through a pointer. Arrays decay to pointers, and pointer arithmetic moves in units of the pointed-to type.
  • All function arguments are pass by value. To modify a caller’s variable, pass a pointer to it. Use const parameters to document read-only intent.
  • Know where your memory lives. Global variables last the whole program, local variables live on the stack, and dynamic memory from malloc lives on the heap until you free it.
  • Strings in C are char arrays terminated by '\0'. You must manage buffer sizes manually and use functions like strlen, strcpy, strcmp, and strcat instead of std::string methods.
  • stdio provides buffered I/O through FILE * pointers. Low-level I/O uses file descriptors and system calls like read, write, and open.
  • C has no exceptions. Use return codes for errors and goto cleanup to release resources in reverse order.
  • Function pointers replace lambdas. qsort is the classic example — pass a comparison function to sort any type.
  • exit terminates from anywhere. Use it for fatal errors, and register cleanup that must always run with atexit.
  • extern "C" bridges C and C++. It turns off name mangling so the C++ linker can find C functions.
  • Always know who owns a pointer. The owner — and only the owner — calls free.

Es un mundo nuevo, but you have the C++ foundation to build on. The syntax will feel familiar even when the idioms are different. Write small programs, compile them with cc, and get comfortable with the compiler’s warnings — they are your best amigo.

Buena suerte — you’ve got this.


Content outline and editorial support from Ben. Words by Claude, the Opus.