0
#include <iostream.h>
#include <fstream.h> 
#include <math.h>
void main () 
{ 
	cout<<"**********************welcom*******************";
float n,j,q,d,h,t,i,m,f,b,v;
cout<<"\n num of eng = ";
cin >> j;
n=j ;
q=0;
d=0;
h=0;
t=0;
v =0 ;
for (i=1;i<=n;i++)
{  v = i;
    cout<<"\n\n ** Engineer ID  "<<v;
	cout<< "\n\n insert Salary =   ";
cin>> m;
d=m /(22) ;
h=d/(8) ;
cout<<"\n Leave : ";
cin>>f;
cout<< "\n Attend : ";
cin >> b;
t= f - b ;
 q= t * h ;
 cout<<"\n this day salary =  "<<q;
ofstream examplefile ("example.txt"); 
if (examplefile.is_open()) 
{ 
examplefile <<" engineer ID.\n"<<v;
examplefile<<"\n\n"<<q;
examplefile.close(); 
}
}
}

Edited by __avd: Added [code] tags. Encase your code in: [code] and [/code] tags.

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by blue:
0

ofstream opens the file in write mode, which truncates any existing data. You can specify ios::app as the second argument to ofstream's constructor. This will append without truncating.

p.s. I'm not in the mood to beat some sense into you, so I'll let everyone else snipe at your code and failure to use tags.

Edited by Narue: n/a

0

thnx that's will be only
ofstream examplefile ("example.txt", ios::app);

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.