What is the difference between the librarys like <cstdlib> or <ctime> and the librarys of C <stdlib.h> or <time.h> in Cpp???? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 2

What is the difference between the librarys like <cstdlib> or <ctime> and the librarys of C <stdlib.h> or <time.h> in Cpp????

I saw this function <cstdlib> and <ctime> in a program that create a random numbers but, what is de difference if i write the same program but i include de Library Stdlib or Time common???? thanks

25th Feb 2018, 4:31 AM
no one
no one - avatar
1 Respuesta
+ 3
Mostly they are very similar. The main difference is that xxxx.h is a C header while cxxxx is a C++ header. The C versions are provided for compatibility with C. Being C++ headers, the Cxxx libraries are embedded into a namespace (std) while xxxx.h headers make their definitions in the global namespace. If you are coding C++ I would suggest using the cxxxx libraries and make use of namespaces for clarity in your code. There are a few other specific differences, but instead of describing them, I will point you to: http://www.cplusplus.com/reference/clibrary/
25th Feb 2018, 5:57 AM
Kevin Hernandez
Kevin Hernandez - avatar