0
Can \n is used only inside string of cout ?
3 Answers
+ 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.
+ 4
ansul sharma yes it's always enclosed in a inverted commas because strings and character needs to be enclosed in " " and ' ' respectively .
+ 1
It means where ever it is used it must be enclosed within inverted commas , am i right?