I/O using a STL container
http://www.shreve-lib.org
I am new to C++ programming using the STL Library. Can someone demostrate a code snippit that would equate the same performance as this:
#include <fstream.h>
#include <iostream.h>
int main()
{
char HaveTextArray[250], *HavePtr,HaveFile[20];
HaveFile="HaveTextFile.txt";
HavePtr=&HaveTextArray;
ofstream Text_file(HaveFile);
//Creates an instance of ofstream, and opens HaveTextFile.txt
Text_file<<"This text will be placed into the file HaveTextFile.txt";
//Outputs to HaveTextFile.txt through Text_file
Text_file.close();
//Closes up the file
ifstream Text_file(HaveFile)
//Opens for reading the file
while(HavePtr!=EOF) {
//Reads a string - up to 250 characters long - from the file
Text_file>>HavePtr;
HavePtr++;
}
cout<<HaveTextArray;
Text_file.close();
//Close the file.
}
/*
Now how do I do the samething using a contain in the STL where a class holds the data container?
-----------------------------------------------------------------------------------
*/
// Setup a class to hold the container:
using STD;
class StorageContainer {
std::Map(char Array[250]);
}
// I may not have set this up right, but you see what is am trying to do
/* How would I use "StorageContainer" to load up the "Array" varable, STORE IT into a file called "Text_File" and retrieve the
data from the "StorageContainer" class's STL container?
*/