By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,382 Members | 1,567 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,382 IT Pros & Developers. It's quick & easy.

how to make this programm with class????

P: n/a
how can i make this programm with class????

#include <fstream>
#include <cstdlib>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;

int main()
char temp_char [200];
string file1,file2;
int i=0;

ifstream indata;"config.txt");
cerr << "Error: file could not be opened" << endl;

int first_row=true;
while (!indata.eof())
while (indata.getline(temp_char,200,'\n'))
if (first_row)
char * buffer;
int long size;
buffer = new char [size];//allocate memory for file content

ifstream examplefile (;
ofstream fout (;
if (! examplefile.is_open())
{ cout << "this thing doesn't work "; exit (1); }

while (! examplefile.eof() )
examplefile.getline (buffer,size);//get line tou *.txt file
fout << buffer << endl;
fout <<"\n\nthe lines of this *.txt are: \t"<<i<<endl;
cout <<"\nthe procedure has been done"<<endl;
return 0;


Oct 25 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
What do you mean?
Oct 25 '05 #2

P: n/a
ben wrote:
What do you mean?

The OP asked, "how can i make this programm with class?" by which I
assume he means, How can I write this program with style and panache?
You know, really classy code!

My first suggestion would be to indent the source code (n.b., one line
of the OP's code *is* indented, making me think this is the OP's habit,
not a cut-n-paste problem), and my second suggestion would be to
consult our previous comments on what is essentially the same code:

If the OP meant, how can I incorporate this code in a class, well, that
depends on how it will be used, but a good C++ book would be of help.
Such a book is _Accelerated C++_ by Koenig and Moo.

Cheers! --M

Oct 25 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.