Write text to a file
This example uses streams to write text to a file
#include<iostream.h>
#include<fstream.h>
int main()
{
// first lets output to a file
ofstream fout(”sample.txt”);
fout << “programmershelp” << endl;
fout.close();
char str[20];
//read in the file
ifstream fin(”sample.txt”);
fin >> str;
fin.close();
//display sample.txt contents
cout << “data read from file: ” << str << endl;
return 0;
}
Related posts:
- cppoctdechex Octal / Hexadecimal / Decimal conversion #include <iostream.h> #include <iomanip.h>...
- Display a CSV file Display a CSV file CSV files are common formats to...
- create a text file Private Sub Form_Load() Dim objFSO As New FileSystemObject Dim objFile...
- More accurate text counter This is a more accurate counter than our previous example...
- Saving a CSV file to a database Create a database in access called stock.mdb . Now create...
Related posts brought to you by Yet Another Related Posts Plugin.



















































Post a comment