0

Why do we use #include<iostream> in c++ language it's compulsory or optional ?

C++

5th Mar 2021, 4:44 PM
muhammad nafi'u
muhammad nafi'u - avatar
4 Respuestas
+ 5
iostream is used to handle input and output. If you don't need either of those, you don't need to include it. But it's really rare to not include for a console application.
5th Mar 2021, 4:55 PM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 4
BeegCat do you mean this program ?👇 https://code.sololearn.com/cVjeRdabhB4N/?ref=app It's nothing complicated here, you just need to know some basic things including 1) what exactly does " #include " directive do 2) what does header files contain Ans 1) when you type "#include <iostream>" or "#include <stdio.h>" all that preprocessor do is find the header file with the following name and literally copy paste all it's content in your file Ans 2) although Martin Taylor already explained most of it, but here's a gist of it. A header file "ideally" only contains function declerations and macro definitions in it ( all the definitions exist in a binary which is linked to your program at the time of linking ) What I did was to simply put the function declaration of "printf()" in my code manually and made use of the fact that gcc by default linkes "libc" ( where the function defination of it exists ) to the program. And thus was able to use it without including any header.
6th Mar 2021, 4:09 AM
Arsenic
Arsenic - avatar