+ 4

Why in C++ , we have to start with #include <iostream> ?

Please reply...

28th Dec 2020, 3:23 AM
Carbon dioxide
Carbon dioxide - avatar
11 ответов
+ 10
It's not mendatoy. You can also skip it if your program is not doing any standard I/O operations. or you can just declare them manually in your source file here is an example 👇 https://code.sololearn.com/cVjeRdabhB4N/?ref=app
28th Dec 2020, 3:33 AM
Arsenic
Arsenic - avatar
+ 9
Jeff's JK (INACTIVE) It's a library to perform input / output operation.
28th Dec 2020, 3:26 AM
A͢J
A͢J - avatar
+ 6
Thanks for the answer everyone...
28th Dec 2020, 3:35 AM
Carbon dioxide
Carbon dioxide - avatar
+ 6
Flash you are absolutely right 🙂 I did some research on it and found out that after VS2015 , they moved defination of functions like printf() and scanf() inline into the <stdio.h> and other CRT headers, so now linker can't find their definations if this code is run as it is. But It can be resolved if we link "legacy_stdio_definitions.lib" by explicitly giving it as linker input before compiling the code. That being said the only purpose of this code was to tell OP that "#include<iostream>" need not to be the first line of every C++ program.👍
28th Dec 2020, 7:28 AM
Arsenic
Arsenic - avatar
+ 2
Arsenic will this run on msvc? .. no! why it works on gcc? because, gcc (linux) links to libc.so by default. so, i think your solution may not be portable to all compilers.
28th Dec 2020, 4:48 AM
Flash
+ 2
Without this you cannot use built-in function of input output operations that's why you include this library.
29th Dec 2020, 10:45 AM
Aniket Kandara
Aniket Kandara - avatar
+ 2
Ohh...Ok...
29th Dec 2020, 10:47 AM
Carbon dioxide
Carbon dioxide - avatar
+ 2
It includes the declarations of the basic standard input-output library in C++ and it is included because it's functionality is going to be used later on the program. ☺️ 👍 🍓 ⛰️
30th Dec 2020, 3:17 AM
K.S.S. Karunarathne
K.S.S. Karunarathne - avatar
- 1
Have you got the answe now 😄 Jeff's JK 😄
29th Dec 2020, 10:48 AM
Aniket Kandara
Aniket Kandara - avatar