473,405 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

how to make this programm with class????

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;

indata.open("config.txt");
if(!indata)
{
cerr << "Error: file could not be opened" << endl;
exit(1);
}

int first_row=true;
while (!indata.eof())
{
while (indata.getline(temp_char,200,'\n'))
{
if (first_row)
{
file1=temp_char;
first_row=false;
//cout<<file1<<endl;
}
else
file2=temp_char;
//cout<<file2<<endl;
}
}
indata.close();
char * buffer;
int long size;
buffer = new char [size];//allocate memory for file content

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

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

}

Oct 25 '05 #1
2 1345
ben
What do you mean?
Oct 25 '05 #2
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:

http://groups.google.com/group/comp....8fb428c516f654

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Toni | last post by:
How can I insert a Backgroundimage in my C++ programm? Microsoft Visual Studio C++, Win 32 Konsolenanwendung. Can you answer me in germany, because my english is very bad. An example where very...
0
by: Toni | last post by:
How can I insert a Backgroundimage in my C++ programm? Microsoft Visual Studio C++, Win 32 Konsolenanwendung. Can you answer me in germany, because my english is very bad. An example where very...
0
by: Alexander F?hrmann | last post by:
Grüß euch! Wir haben hier in der Firma ein Problem mit Access! Sobald man im Access den VBA-Editor aufrufen will, kommt folgender fehler! -------------------- Runtime Error!
6
by: TIM | last post by:
for example i have one simple programm int main() { int test = NULL; while(1){ printf("%d\n",test); getch(); test++; }
11
by: nico | last post by:
Hello I have write this program that retrieve all directory and subdirectory recursively of a given directory given in parameter. For each directory, the script find all user permission for the...
2
by: Marcus Schaefer | last post by:
Hello, I have a queer problem in my project (Visual Basic Express 2005): When I create a new Instance of one of my classes dim data as new CData(fname) <-- crash ! Dim frm as new...
83
by: deppy_3 | last post by:
Hi.I am started learning Programm language C before some time.I am trying to make a programm about a very simple "sell shop".This programm hasn't got any compile problem but when i run it i face...
2
by: LordChaos | last post by:
Dear all, I am a newbie in Java, I got the following problem: I am going through a list of directories. The programm looks inside each directory for specific files and writes them in an...
1
by: Olaf | last post by:
Hi, I try to design a program which has to run on console. There is only one exe/binary and depend on the calling name argv the different tasks/commands should be performed as aliases. It's the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.