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?
1 Answer
+ 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.