fstream file("newdata.txt",ios::out | ios::binary);
char word = {'a','e','i','o','u'};
for(int i=0; i<5; i++)
{
file.write(&word[i],sizeof(word[i]));
file<<"\n";
}
I am trying to write all the vowels to a binary file with each vowel in one line. But the newline is always ignored. I have tried file.put('\n') as well, but it never worked. Any way out? Thanks for taking your time.
Aucun commentaire:
Enregistrer un commentaire