Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Name: M.

Faseeh Nasir
Subject: Programming Fundamental
I’D: 39604
Assignment No : 04

Task 1

#include <iostream>
#include <fstream>
using namespace std;
int main() {
ofstream faseeh;
faseeh.open("C:\\Users\\Student\\Desktop\\faseeh.pdf");
faseeh.close();
cout<<"File Created ";
}

Task 2

#include <iostream>
#include <fstream>
using namespace std;
int main() {
ofstream faseeh;
faseeh.open("C:\\Users\\Student\\Desktop\\faseeh.docx");
faseeh<<"mY bEsT Frztz DaNi";
cout<<"Write operation perform successfully ";
faseeh.close();
}
Task 3

#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream faseeh;
string str;
faseeh.open("C:\\Users\\Student\\Desktop\\faseeh.docx");
while (getline (faseeh,str)){
cout<<str;
}
faseeh.close();
}

Task 4:
#include<iostream>
#include<fstream>
using namespace std;
int main{
ifstream infile;
ofstream onfile;
char str;
infile.open("C:\\Users\\FASEEH\\Desktop\\TEST.docx");
onfile.open("C:\\Users\\FASEEH\\Desktop\\TEST.docx");
while(infile.get(str)){
onfile.put(str);
}
cout<<”Data copied successfully”;
infile.close;
onfile.close;
}
Task 5:
#include<iostream>
#include<fstream>
using namespace std;

int main{
int value=remove("C:\\Users\\FASEEH\\Desktop\\TEST.docx");

if (value==0) {

cout<<"File Deleted Successfully";


}

else{

cout<<"File Not Deleted";


}
}

You might also like