Basic file operations in C++ involve opening, reading from, and writing to files. The key classes for input/output with files are ofstream for writing, ifstream for reading, and fstream for both reading and writing. A file must first be opened before performing any operations on it. Common operations include writing data to files with put() or write(), reading data from files with get() or read(), and closing files after completion. Proper opening modes and error handling should be used to ensure successful file input/output.
File Handling is used in C language for store a data permanently in computer.
Using file handling you can store your data in Hard disk.
http://www.tutorial4us.com/cprogramming/c-file-handling
File Handling is used in C language for store a data permanently in computer.
Using file handling you can store your data in Hard disk.
http://www.tutorial4us.com/cprogramming/c-file-handling
Practical Class 12th (c++programs+sql queries and output) Aman Deep
Just download this and do some specific changes in the name section and roll no section . and submit it as it is to your teacher this will surely work and help you out your class 12th board practicals exam . no worries ! ENJOY :) !
All information in a file is always in binary form or a series of ones and zeros. A document includes any file you have created. It can be a true text document, sound file, graphics, images, or any other type of information the computer can create, store, or size from the internet.
COURSE TITLE: SOFTWARE DEVELOPMENT VI
COURSE CODE: VIT 351
TOPICS COVERED:
FILES
FILES I/O STREAM
TYPES OF FILES
DRAWBACKS OF TRADITIONAL METHOD OF DATA STORAGE
CONCEPT OF BUFFER
MODES OF FILE OPENING
END OF FILE
PROCESSORS DIRECTIVES
MACROS
TYPES OF MACROS
DIFFERENCE BETWEEN MACROS AND FUNCTIONS
QUIZ SET 5
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
2. 2
Learning Objectives
C++ I/O streams.
Reading and writing sequential files.
Reading and writing random access files.
3. 3
Table 12-1
File Name and Extension File Contents
M Y P R O G .B A S BASIC program
M E N U .B A T DOS Batch File
I N S T A L L .D O C Documentation File
C R U N C H .E X E Executable File
B O B .H T M L HTML (Hypertext Markup Language)
File
3 D M O D E L .J A V A Java program or applet
I N V E N T .O B J Object File
P R O G 1 .P R J Borland C++ Project File
A N S I .S Y S System Device Driver
R E A D M E .T X T Text File
6. 6
4.1 What is a File?
A file is a collection on information, usually
stored on a computer’s disk. Information
can be saved to files and then later reused.
7. 7
4.2 File Names
All files are assigned a name that is used for
identification purposes by the operating
system and the user.
8. 8
Setting Up a Program for File Input / Output
Before file I/O can be performed, a C++
program must be set up properly.
File access requires the inclusion of
# include <fstream>
9. Input &Output with files
Input / Output with files
C++ provides the following classes to perform
output and input of characters to/from files:
ofstream: Stream class to write on files
ifstream: Stream class to read from files
fstream: Stream class to both read and write
from/to files.
9
10. 10
Path of file
Before data can be written to or read from a
file, the file must be opened.
ifstream inputFile;
inputFile.open(“customer.dat”);
// Path of file using :
ifstream fin("D:data.txt ");
11. 11
C++ Files and Streams
Why use File Handling
For permanent storage.
The transfer of input - data or output - data
from one computer to another can be easily
done by using files.
For read and write from a file you need
another standard C++ library called fstream,
which defines three new data types:
12. How to achieve File Handling
For achieving file handling in C++ we
need follow following steps
• Naming a file
• Opening a file
• Reading data from file
• Writing data into file
• Closing a file
12
13. Input &Output with files
Input / Output with files
C++ provides the following classes to perform
output and input of characters to/from files:
ofstream: Stream class to write on files
ifstream: Stream class to read from files
fstream: Stream class to both read and write
from/to files.
13
14. Functions use in File Handling
Function Operation
open() To create a file
close() To close an existing file
get() Read a single character from a file
put() write a single character in file.
read() Read data from file
write() Write data into file.
14
15. 15
Closing a File
A file must be close after completion of all operation related to
file. For closing file we need close() function.
Syntax
outfile.close();
Defining and Opening a File
The function open() can be used to open multiple files that use
the same stream object.
Syntax
file-stream-class stream-object;
stream-object.open("filename");
Example
ofstream outfile; // create stream
outfile . open ("data1"); // connect stream to data1
16. File Opening mode
Mode Meaning Purpose
ios :: out Write Open the file for write only.
ios :: in read Open the file for read only.
ios :: app Appending Open the file for appending data to end-of-file.
ios :: ate Appending take us to the end of the file when it is opened.
16
Example
fstream file;
file.Open("data . txt", ios :: out | ios :: in);
18. 18
File Open Modes
ios:: app - (append) write all output to the end of file
ios:: ate - data can be written anywhere in the file
ios:: binary - read/write data in binary format
ios:: in - (input) open a file for input
ios::out - (output) open afile for output
ios: trunc -(truncate) discard the files’ contents if
it exists
19. // basic file operations writing to file
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream myfile;
myfile.open ("example.txt");
myfile << "Writing this to a file.n";
cout<<" myfile " << "Writing this to a file.n";
myfile << "Writing this to a file.n";
cout<<" myfile " << "Writing this to a file.n";
myfile << "Writing this to a file.n";
cout<<" myfile " << "Writing this to a file.n";
myfile << "Writing this to a file.n";
myfile.close();
return 0;
}
19
20. Writing to file
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char x = 's';
int d = 77;
double i = 3.14;
ofstream fout("data2.txt");
fout << x << d << ' ' << i ;
cout << x << d << ' ' << i ;
fout.close();
cout << "File Completedn";
return 0;
}
20
21. #include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream fout;
fout.open("FF.txt");
fout << "HELLOW FILE .n"<< "WELCOME YOU PROGRAMn"
<< "WHAT DA YOU LIKE OF MEn";
fout.close();
}
21
22. // writing in file
#include<iostream> //divide by 7
#include <fstream>
using namespace std;
int main()
{
ofstream fout("data.txt");
for(int i=4;i<=200;i++)
{
if(i%7==0)
fout<<i<<" : divide by Two (7) ."<<"n";
}
fout.close();
}
22
23. #include<iostream>//prime number
#include<fstream>
using namespace std;
int main()
{
ofstream fout("prime2.txt");
int num;
bool prime;
cout << "Please enter a positive integer" << endl;
cin >> num;
for(int i = 3; i <= num; i++){
prime = true;
for(int n = 2; n <= i - 1; n++){
if(i % n == 0){
prime = false;
}
}
if(prime){
cout << i << " is prime" << endl;
fout << i << " is prime" << endl;
}
}
}
23
24. #include<iostream>// !x=x*(x-1)*(x-2)….
#include<fstream>
using namespace std;
int main()
{
ofstream fout("factial2.txt");
// Variable Declaration
int counter, n, fact = 1;
// Get Input Value
cout<<"Enter the Number :";
cin>>n;
//for Loop Block
for (int counter = 1; counter <= n; counter++)
{
fact = fact * counter;
}
fout<<n<<" Factorial Value Is "<<fact;
fout.close();
cout<<n<<" Factorial Value Is "<<fact;
return 0;
}
24
25. 25
Testing for Open Errors
dataFile.open(“cust.txt”, ios::in);
if (!dataFile)
{
cout << “Error opening file.n”;
}
26. 26
Another way to Test for Open
Errors
dataFile.open(“cust.dat”, ios::in);
if (dataFile.fail())
{
cout << “Error opening file.n”;
}
27. // writing on a text file
// writing on a text file
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream myfile ("examplett.dat");
if (myfile.is_open())
{
myfile << "This is a new file created in cpp.n";
myfile << "This is another line.n";
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
27
28. file operations in C++
#include <fstream>
#include <iostream>
using namespace std;
int main ()
{ ofstream myfile;
myfile.open ("example22.txt");
myfile << "Writing this to a file.n";
myfile<<"Hope fine”" << endl;
myfile<<"this frist file ”" << endl;
myfile.close();
return 0; }
28
29. #include <fstream>
#include <iostream>
using namespace std;
int main()
{ char FirstName[30], LastName[30];
int Age;
char FileName[20];
cout << "Enter First Name: ";
cin >> FirstName;
cout << "Enter Last Name: ";
cin >> LastName;
cout << "Enter Age: ";
cin >> Age;
cout << "nEnter the name of the file you want to create:. .txt ";
cin >> FileName;
ofstream Students(FileName, ios::out);
Students << FirstName << "n" << LastName << "n" << Age;
cout << "nn";
return 0;
}
29
30. Write to file
#include<iostream>
#include <fstream>
using namespace std;
int main()
{ ofstream fout;
fout.open("FFFF.txt");
fout << "Asalamualikom hope fine .n"
<< "WELCOME TO GE 211 FILE SECTION PROGRAMn"
<< "HOPE TO DO WELL IN SECOND MEDTERM
EXAMn";
fout.close();
}
30
31. //Write the odd number in file
#include<iostream>
#include <fstream>
using namespace std;
int main()
{ ofstream fout;
fout.open("E:firsteee.txt");
int i,j;
for(i=2;i<30;i+=2)
{
fout<<i<<"t";
cout<<i<<"t";}
fout.close();
}
31
32. // print in file Even number 1:30
#include<iostream>
#include <fstream>
using namespace std;
int main()
{ ofstream fout;
fout.open("D:firstExa.txt");
int i,j;
for(i=1;i<30;i+=2)
fout<<i<<"t";
fout.close();
}
32
34. //write equation for this series
#include<iostream>
using namespace std;
int main()
{
int i,j,m,n,sum;
sum=0;
cin>>n;
for(i=1 ;i<=n ;i++)
{
m=i*i;
sum=sum+m; }
cout<< "seque="<<sum<< endl;
}
34
35. #include<iostream> // using both file and screen
#include <fstream>
using namespace std;
int main()
{
ofstream fout;
fout.open("xxxx.txt");
int i,j,m,n,sum;
sum=0;
cout<<"equation for this series ="<<endl;
cin>>n;
for(i=1 ;i<=n ;i++)
{
m=i*i;
sum=sum+m; }
cout<< "seque="<<sum<< endl;
fout<< "seque= written in file is="<<sum<< endl;
fout.close();
}
35
36. #include<iostream>
#include <fstream>
#include<cmath>
using namespace std;
int main()
{
float i,m,n,b,a,y,x,s;
y=0;
b=2;
cout<<"enter the last power ofn";
cin>>n;
cout<<"enter the volue of(x)n";
cin>>s;
for(i=1;i<=n;i++){
x=pow(s,i);
a=pow(b,i);
m=x/a;
y=y+m;
}
cout<<"y= "<<y;
}
36
37. #include<iostream>
#include <fstream>
#include<cmath>
using namespace std;
main()
{ofstream fout;
fout.open("D:UUUU.txt");
float i,m,n,b,a,y,x,s;
y=0;
b=2;
cout<<"enter the last power ofn";
cin>>n;
cout<<"enter the volue of(x)n";
cin>>s;
for(i=1;i<=n;i++){
x=pow(s,i);
a=pow(b,i);
m=x/a;
y=y+m;
}
cout<<"y= "<<y;
fout<<"y= "<<y;
fout.close();
}
37
44. // writing on a text file
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream myfile ("example.txt");
if (myfile.is_open())
{
myfile << "This is a line.n";
myfile << "This is another line.n";
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
Slide 6- 44
45. // reading a text file
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string line;
ifstream myfile ("example.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
Slide 6- 45
46. Using fout
Slide 6- 46
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
int main (int aaa,char *avg[])
{
ofstream fout ("my_out.txt");
fout<<" Assalamualikom Hope fine" << endl;
fout<<"Please tray good in second exam this frist file " << endl;
return 0;}
47. Write in file
#include <fstream>
#include <iostream>
using namespace std;
int main( )
{
//cout<<"Exam1n";
// ifstream ;// read
// ofstream ;// write
// fstream;//read &write
ofstream myfile;
myfile.open("kkkk.txt");
myfile<< "Exam1 is okn";
myfile<< "please tray good in second exam";
myfile.close();
return 0;
}
47
48. Using app
#include <fstream>
#include <iostream>
using namespace std;
int main( )
{
/*cout<<"Exam1n";
ifstream ;// read
ofstream ;// write
fstream;//read &write*/
fstream myfile;
myfile.open("kkkk.txt",ios ::out|ios::app);
//myfile<< "Exam1 is okn";
myfile<< "please tray good in second exam****************n";
//cout<<myfile.rdbuf();
myfile.close();
return 0;
}
48
49. Read from file
#include <fstream>
#include <iostream>
using namespace std;
int main( )
{
/*cout<<"Exam1n";
ifstream ;// read
ofstream ;// write
fstream;//read &write*/
ifstream myfile;
myfile.open("kkkk.txt");
//myfile<< "Exam1 is okn";
//myfile<< "please tray good in second exam";
cout<<myfile.rdbuf();
myfile.close();
system("pause");
return 0;
}
49
53. Basic file operations
// basic file operations
#include <iostream>
#include <fstream>
//#include <ifstream>
//#include <ofstream>
using namespace std;
int main () {
ofstream myfile;
myfile.open ("XXX.txt");
myfile << "**Writing this to a file.n";
myfile << "****Writing this to a file.n";
myfile << "*********Writing this to a file.n";
myfile.close();
system("PAUSE");
return 0;
}
53
54. Basic file operations
#include <iostream>
#include <fstream>
using namespace std;
int main (int argc, char *arvg[ ])
{
ofstream fout("XXX.txt");
fout << "**Writing this to a file.n";
fout << "****Writing this to a file.n";
fout << "*********Writing this to a file.n";
system("PAUSE");
return EXIT_SUCCESS;
}
54
55. Read from file
#include <fstream>
#include <iostream>
using namespace std;
int main( )
{
/*cout<<"Exam1n";
ifstream ;// read
ofstream ;// write
fstream;//read &write*/
ifstream myfile;
myfile.open("finoncy.txt");
//myfile<< "Exam1 is okn";
//myfile<< "please tray good in second exam";
cout<<myfile.rdbuf();
myfile.close();
return 0;
}
55
56. // reading a text file
#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;
int main () {
char buffer[256];
ifstream examplefile ("kk.txt");
if (! examplefile.is_open())
{ cout << "Error opening file"; exit (1); }
while (! examplefile.eof() )
{
examplefile.getline (buffer,100);
cout << buffer << endl;
}
return 0;
} 56
57. // writing on a text file
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream myfile ("example.txt");
if (myfile.is_open())
{
myfile << "This is a line.n";
myfile << "This is another line.n";
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
57