Must iostream always be included? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

Must iostream always be included?

Must #include <iostream> be in the header of every C++code? Could you get by using other libraries instead?

30th Aug 2019, 4:28 AM
Clavis Janes
Clavis Janes - avatar
1 Réponse
+ 6
What headers you need to include depends on what your program does. Does your program require input and output streams? If so, you need <iostream>. If you're asking about a different way to do console I/O, you can check <cstdio> (or <stdio.h>), which contains functions like printf() and scanf(). #include <cstdio> int main() { printf("Hello, World."); } If your program does not require any input and output functionalities, a program without including any headers, as such: int main() { } is completely valid.
30th Aug 2019, 4:57 AM
Hatsy Rei
Hatsy Rei - avatar