+ 4
Why in C++ , we have to start with #include <iostream> ?
Please reply...
11 odpowiedzi
+ 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
+ 9
Jeff's JK (INACTIVE) It's a library to perform input / output operation.
+ 6
Thanks for the answer everyone...
+ 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.👍
+ 5
Just additional answers to I Am Groot ! I Hope these helps.
https://www.sololearn.com/Discuss/105533/i-don-t-know-whether-u-need-include-iostream-is-it-the-beginning-of-any-programm
https://www.sololearn.com/Discuss/84085/why-do-i-need-to-include-iostream-in-order-to-use-cout-even-though-i-use-std-to-access-it-std-cout
https://www.sololearn.com/Discuss/940337/reason-for-the-standard-coding-template-in-c
+ 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.
+ 2
Without this you cannot use built-in function of input output operations that's why you include this library.
+ 2
Ohh...Ok...
+ 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. ☺️ 👍 🍓 ⛰️
- 1
Have you got the answe now 😄 Jeff's JK 😄