0

Can \n is used only inside string of cout ?

12th Sep 2019, 12:37 PM
ansul sharma
ansul sharma - avatar
3 Réponses
+ 4
It's used in strings but not only when you output string on console with cout , it's also used when you write data to files. in case you don't know what is mean by writing in files: we do something like this : fstream myfile("data.txt",ios::out); //creates object of file stream classs and opens a file named data.txt in write mode to output something in it myfile<<"This is my text \n in my file "; //writes text in file on two different lines. myfile.close(); //close file so resources are available for other tasks.. If you don't understand this don't worry . focus on what you are learning. you'll understand this sooner. anyone know where else it's used? please let me know.
12th Sep 2019, 12:47 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 4
ansul sharma yes it's always enclosed in a inverted commas because strings and character needs to be enclosed in " " and ' ' respectively .
12th Sep 2019, 1:14 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 1
It means where ever it is used it must be enclosed within inverted commas , am i right?
12th Sep 2019, 1:05 PM
ansul sharma
ansul sharma - avatar