+ 3

What are three major differences in between \n and endl?

8th Aug 2020, 6:35 AM
Ghulam Mujtaba
Ghulam Mujtaba - avatar
2 odpowiedzi
+ 8
https://www.google.com/amp/s/www.geeksforgeeks.org/endl-vs-n-in-cpp/amp/ endl is manipulator while \n is character. endl doesn’t occupy any memory whereas \n is character so It occupy 1 byte memory. We cannot write endl in between double quotation while we can write \n in between double quotation like cout<<"\n"; it is right but cout<<"endl"; is wrong. We can use \n both in C and C++ but, endl is only supported by C++ and not the C language. Hope this helpful! Programming is fun! 😄🤗
8th Aug 2020, 6:48 AM
WenHao1223
WenHao1223 - avatar
+ 1
\n is a character , endl is not endl is slow , \n is not endl flushes the Ouput buffer , nothing so with \n
8th Aug 2020, 6:50 AM
Hima
Hima - avatar