حل شدہ اسائنمنٹس ڈانلوڈ کرنے کے لئے پہلے رجسڑ کریں پوسٹ کا جواب بھی دیا کریں جس اسائمنٹ کا حل نہ ملے اس کی سوالات کی فائل اپلوڈ کی کریں تاکہ اُس کا حل پوسٹ کیا جا سکے

How To Write Program Electra City Bill Reading From Text File in C++

This Section is For Vu Old Solved Assignments From Instructors which will be help full for you finding your Solution.
Forum rules
Post Only Old Assignments Which are Solved By Instructors Thanks
User avatar
Ali Raza Tawary
★★★★★★★★★★★★★
★★★★★★★★★★★★★
Posts: 190
Joined: Fri Dec 22, 2017 8:10 am
Location: Lahore
Contact:
Status: Offline

Medals

How To Write Program Electra City Bill Reading From Text File in C++

Post by Ali Raza Tawary »

This Code is Help Full In C++ Files Handling . This Code Works and Creates out put text File and The Other Part of The Program Reads That File and Show The Contents of that file on Console . Very Help full In C++ Programming of CS201
Code is Given Below and exe File is in Attachments

Answer of the Assignment
 //mc100400117
#include<iostream.h>
#include<fstream.h>
 
main()
{
       ofstream outFile;//defineing file handler
       //charcter string which we want save and show on the secreen
char outputTex1[10000]="                   Electricity Consumer Bill @---------------------------------------------------------------------------@Reference No        Tariff        Load       Old A/C No @123456789123456     2              1              123456789123456 @---------------------------------------------------------------------------@Name and Address    @XYZ Lahore Pakistan @---------------------------------------------------------------------------@Reading             MF     Total Unit Consumed    Total Cost of electricity @55671               1      328                      9999@---------------------------------------------------------------------------@Month             Units     Bill              Current Bill            10732@Jan-11            312       5000              Arrears                 0@Feb-11            312       5000              Tariff Subsidy          NA@Mar-11            312       5000              Payable within Duedate  10732  @---------------------------------------------------------------------------@" ;
//opening the file or creating a new file
outFile.open("myFileOut.txt",ios::out);
//erorr checking
if (!outFile)
{
             cout<<"Can't open input file named"<<"myFileOut.txt"<<endl;
             exit(1);
}
//writing string in the file
             outFile<<outputTex1;
             //closing file and saving Data
             outFile.close();
             //defining the file handler for reading purpose
fstream inFile;
//opining the perivious file which we save
inFile.open("myFileOut.txt",ios::in);
 
//pringting charters with beautiful manner looking nice on the screen
inFile.getline(outputTex1,100,'@');
 
cout<<outputTex1<<endl;
inFile.getline(outputTex1,100,'@');
cout<<outputTex1<<endl;
inFile.getline(outputTex1,100,'@');
cout<<outputTex1<<endl;
inFile.getline(outputTex1,100,'@');
cout<<outputTex1<<endl;
inFile.getline(outputTex1,100,'@');
cout<<outputTex1<<endl;
inFile.getline(outputTex1,100,'@');
cout<<outputTex1<<endl;
inFile.getline(outputTex1,100,'@');
cout<<outputTex1<<endl;
inFile.getline(outputTex1,100,'@');
cout<<outputTex1<<endl;
inFile.getline(outputTex1,100,'@');
cout<<outputTex1<<endl;
inFile.getline(outputTex1,100,'@');
cout<<outputTex1<<endl;
inFile.getline(outputTex1,100,'@');
cout<<outputTex1<<endl;
inFile.getline(outputTex1,100,'@');
cout<<outputTex1<<endl;
inFile.getline(outputTex1,100,'@');
cout<<outputTex1<<endl;
inFile.getline(outputTex1,100,'@');
cout<<outputTex1<<endl;
inFile.getline(outputTex1,100,'@');
cout<<outputTex1<<endl;
inFile.getline(outputTex1,100,'@');
cout<<outputTex1<<endl;
 
//closing file
inFile.close();
 
// this integer only for Runing over file into devc++ when we prompt than our file will be shown on the sceen comletey rater than
//we open it in Dos mode we can see our result on devC++ screen
// There for I defined int i and prompt
 
int i;
cin>>i;
        
}
Image

Last 10 Members Who Visited This Topic

User avatar Ali Raza Tawary (3)

Who is online

Users browsing this forum: No registered users and 1 guest