C++ Program implementing File Streaming :Storing array of numbers in a data file
#include <stdlib.h>
#include <iostream.h>
#include <fstream.h>
int main()
{
ifstream fin; // File Pointers
ofstream fout;
int array[4] = { 3, 76, 5, 12 }; // Array of data to be saved
int x; // Loop Counter
fout.open("fstream.txt"); // Create file
for( x = 0; x < 4; x++ )
{
fout << array[x] << endl; // Write array data to file
}
cout<<"Data Has Been Writen..." << endl; // fstream.txt can be found
// @ C:
getch();
fout.close(); // Closes file
return 0;
}
Related Posts : C++ Programs
0 comments:
Post a Comment