Difference between "iostream" or "stdlib.h stdio.h" in #include

2

I'm learning to program in c ++, and I'd like to know the difference between programming with the library

#include <iostream>

or the libraries

#include <stdlib.h>
#include <stdio.h>

One would use things like std::cout e std::cin and another would use printf e scanf .

I need to know how to program with the two or can I go on only one, which in the case I was learning with std::cout ? Do they have a difference in performace or something?

    
asked by anonymous 05.04.2018 / 06:29

1 answer

6

One is the standard C library I / O, the other is the Standard Template Library (STL) I / O for C ++. There should be no substantial difference in performance between them.

As a professional in the field it is good to know both, because you will find both in third-party code.

In C ++ you have the choice of an OR other, I suggest not mixing because the I / O is buffered (stored temporarily in memory), there the recording in file or display in the console (stdout / cout) may occur in a different order than you expected.

Personally I prefer the C library because of the printf () masks I know best and are employed in many different C languages, but do not take this as a recommendation. Use one and the other and see which one pleases more. Many people would say that if you program in C ++ you should avoid the default C library, preferring STL.

    
05.04.2018 / 06:44