I will gladly post my code =D
EDIT : Updated with Dave's Correction's (Thanks Dave =D )
Code:
#include <iostream> /* This is another way to make comments */
#include <iomanip> /* These are the headers we need, so remember to */
#include <fstream> /* use them all wisely. Hopefully you will learn */
#include <sstream> /* past where i have gotten with these tutorials */
#include <string> /* You are our programming legacy, feel honoured.*/
using namespace std;
using namespace std::ios;
class Customer //Class for the C++ Tutorial Register
{
private:
public:
ostringstream File_ID;
ofstream b_file();
Customer();
~Customer();
char Customer::GetData(int id2);
int id2;
int blah;
char* file;
char* memblock;
int y;
int Customer::GetLines(char *file);
}search;
Customer::Customer() //Constructor for the C++ Class
{
};
Customer::~Customer() //destructor for the C++ Class
{
};
int Customer::GetLines(char *file)
{
int y = 0;
string line;
ifstream productlist(file);
if(productlist.is_open())
while (! productlist.eof() )
{
getline (productlist,line);
y++;
}
productlist.close();
return y; //Returns the number of lines in the .txt file.
};
char Customer::GetData(int *id2)
{
ostringstream File_ID;
File_ID<<id2 + ".txt";
fstream b_file(File_ID.str().c_str(), in|ate);
fstream::pos_type size;
char * memblock;
if (b_file.is_open())
{
size = b_file.tellg();
memblock = new char [size];
b_file.seekg (0, ios::beg);
b_file.read (memblock, size);
b_file.close();
}
return memblock[size]; //Returns the text from inside the File_ID.txt
};
So I just had a thought, do you also need to see the main code that uses this class maybe? By the way if u are wondering about the search;'s i didnt know where to declare an object of the class for certain cases. and sorry for being the noob who asks questions =\