basic question help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

basic question help

//here i have not include string library and in compilation it does not giving error but length is defined in string library #include <iostream> using namespace std; int main() { int n; string s="fsdfsf"; n=s.length(); cout<<n; return 0; }

21st Aug 2018, 7:03 AM
Bahubali
Bahubali - avatar
2 Answers
+ 5
Bahubali generally iostream header inclusion assures string inclusion.... Iostream has already included string within itself..but different compiler version may have different behaviour...even though it is provided in iostream, for safety and improved code speed, it's recommended to include individual string header if you are going to use string functions..
21st Aug 2018, 7:42 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
thank u
21st Aug 2018, 8:15 AM
Bahubali
Bahubali - avatar