printf
is usually used in special situations because it is faster than cout
C++ usually uses cout
.
To summarize C++'s Why should I use inside of the traditional
Considering safety and error, scalability and inheritance, <iostream>
is better than <cstdio>
.
printf()
and scanf()
are also good features in themselves, but there are many restrictions for C++ I/O to see. The following is a comparison between C++ (<<
, >>
) and C (
printf() and
scanf()
).
Type-safe: <iostream>
provides a static indication of the type of object the compiler is I/Oing. Conversely, <cstdio>
dynamically determines the type by using %
.
Less error prone: Extensible: Inheritable: <cstdio>
writes %
so the formatter must match the object that it is actually going to I/O. <iostream> can reduce errors because it does not write a
%> token. p>
<iostream>
mechanism allows I/O of user-defined types without changing existing code. <iostream>
mechanism is created from real classes such as std::ostream
or std:stream
, so <cstio>
inherits unlike
FILE. So the things that you define look like streams, and they act like streams.
© 2024 OneMinuteCode. All rights reserved.