Del() function not working ,unable to delete files from program

// ****************************************
// HEADER FILES USED
//*****************************************

#include
#include <conio.h>
#include
#include <stdlib.h>
#include // read from string and write to string using formatting facilities
#include <stdio.h>
#include
#include <stdio.h>
#include
#include <shlobj.h> // to use SHGetFolderPathA
#include <windows.h>
#include <direct.h>
#pragma comment(lib, “shell32.lib”)
using namespace std;
void newmemo();
void openmemo();
void header();
void Del();
//#############################################
// MAIN FUNCTION
//#############################################

void main()
{ system(“cls”);
cout << “\n CASH MEMO version 1.0. Built on Microsoft C++. \n \n\n\n”;
cout<<"\n Coded by :Siddharth Kumar “;
cout<<”\n Class :XII ‘A’";
cout<<"\n School :Oxford public School ";
getch();
system(“cls”);
header();
}

//**********************************************
// HEADER FUNCTION FOR ENTERING CHOICE
//**********************************************

void header(){
int choice;
do{

	cout<<"\n\t1.  Create New Invoice ";
	cout<<"\n\t2.  Open Existing Invoice ";
	cout<<"\n\t3.  Delete File";
	cout<<"\n\t4.  Exit ";

	cout<<"\n\n\t Enter your choice (1-4) ";
	cin>>choice;

	switch(choice)
	{    
	case 1:newmemo();

	case 2:openmemo();


	case 3:Del();

	case 4:cout<<"\n Bye - Bye ";
		     exit(EXIT_SUCCESS); break;

	default :cout<<"\n Wrong Choice";
		     cout<<"\n Press any key to re-enter ";
			 getch();

	}
}while(choice!=3);

}

//***********************************
// NEWMEMO FUNCTION
//***********************************

void newmemo(){
cout << " Enter the total number of Items (MAX. 1000 accepted) : ";
int totalitems;
cin >> totalitems;
cout << “\n”;
const int item = 1000;
int x;
double total;
double cost[item];
double rate[item];
double quantity[item];
total=0;
string name[item];
int spreq; //space required in upname
int strupname; //string length of upname
int maxlenall=20; //max name length
for(x=1;x<=totalitems;x++){
cout << " Enter Product number " << x << " Name (MAX 25 char): ";
cin >> name[x];
cout << " Enter Product number " << x << " Rate (cost per unit in INR) : ";
cin >> rate[x];
cout << " Enter Product number " << x << " Quantity (Unit) : ";
cin >> quantity[x];
cost[x]=rate[x] * quantity[x];
cout << “\n”;
total += cost[x];
}
char path1[ MAX_PATH ];// MAX_PATH IS PRE DDEFINED IN WinDef.h ,used as string size definer

if (SHGetFolderPathA( NULL, CSIDL_APPDATA, NULL, 0, path1 ) != S_OK)  // creating path to store data files for variable path1
{
cout << "";
}
else
{
cout << " ";
}
stringstream pathss1; // streams variable pathss1 from memory to file
string s1;   

pathss1 << path1;  //streaming variable path1 with the help of pathss1
pathss1 >> s1;  // streaming path to store in s1

string billpath1=s1 + "\\CashMemoBills"; // path created for storage of files

mkdir( billpath1.c_str() ); // c_str() return pointer to null-terminated nonmutable array

stringstream ss1;

ss1 << path1 << "\\CashMemobills\\donot_delete.iid";

string iidname = ss1.str(); // return string copy of character array

FILE *file1;
int file1_exists;
const char * filename1=iidname.c_str();
file1=fopen(filename1,"r");
if (file1==NULL) file1_exists=0;
else {file1_exists=1; fclose(file1);}


if (file1_exists==1)
{
   file1=fopen(filename1,"r+b"); // open binary file for read/write
}
else
{
    file1=fopen(filename1,"w+b"); // create binary file for write/read
	ofstream out2(iidname); // opens file for writing with path stream of iidname 
    out2 << "0";
    out2.close();
}   
if (file1!=NULL)
{
   fclose(file1);
}
ifstream in1(iidname);
int num11;
in1 >> num11;
in1.close();
int randomnum1;
randomnum1 = num11+1;
ofstream out1(iidname);
out1 << randomnum1;
out1.close();
ifstream in(iidname);
int num1;
in >> num1;
in.close();
int randomnum;
randomnum = num1;


//open file to start the billing
ofstream file;
char line [] = " Supermarket of RANCHI \n";
stringstream ss;
char path[ MAX_PATH ];
if (SHGetFolderPathA( NULL, CSIDL_PERSONAL, NULL, 0, path ) != S_OK)
{
cout << "";
}
else
{
cout << " ";
}
stringstream pathss; //path string streamer
string s;
pathss << path;
pathss >> s;
string billpath=s + "\\CashMemoBills";
mkdir( billpath.c_str() );
ss << path << "\\CashMemobills\\bill" << randomnum << ".cmb";
string filename = ss.str();
cout << path;
file.open(filename);  //ios::out | ios::trunc        
file << line << endl; 
file << " ################# INVOICE GENERATED SUCCESSFULLY #################\n\n";
file << "\n ID |   PRODUCT NAME   |   RATE (INR) | PRODUCT QUANTITY | PRODUCT TALLY \n \n ";
//temporary end of file to start the loop
cout << "\n\n ################# INVOICE GENERATED SUCCESSFULLY #################\n\n";
cout << "\n ID |   PRODUCT NAME  |  RATE (INR) | QUANTITY | TALLY \n \n";
for(x=1;x<=totalitems;x++){
   strupname=name[x].length();
   spreq=maxlenall-strupname;
   //loop started
   int i;
   file << " ";
   file << x;
   file << "      ";
   file << name[x];
   for(i=0;i<=spreq;i++){
	  //loop for spaces
	  file << " ";
   }
   file << "";
   file << rate[x];
   file << "  \t\t";
   file << quantity[x];
   file << " \t       ";
   file << cost[x];
   file << "\n ";
   cout << " " << x << "      " << name[x] << "";
   for(i=0;i<=spreq;i++){
	  //loop for spaces
	  cout << " ";
   }
   cout << rate[x] << "  \t " << quantity[x] << "        " << cost[x] << "\n";
}
//end of loop
file << "\n \t \t\t\t\t\t      Total is ";
file << total;
file << "\n\n ";
file << __DATE__;
file << " ";
file << __TIME__;
file << "       ";
file << " Invoice ID : #";
file << randomnum;

//close the file
file.close();
cout << "\n \t \t \t\t\t Total is " << total << "\n\n";
cout << " " << __DATE__ <<  " " << __TIME__ << "      " << "Invoice ID : #";
cout << randomnum;
cout << "\n";	
cout << "\n \n Invoice has been generated and saved as bill";
cout << randomnum;
cout << ".cmb.\n Please print the text file saved in documents folder. \n\n Press any key to continue ";
string sys1 = "notepad.exe";
string s3 = sys1+" "+filename;
system(s3.c_str());
getch();
system("cls");
header();
/*if(exitcmd=="N" || exitcmd=="n")
{
	cout << "\n\n";
	newmemo();
}
else if(exitcmd=="O" || exitcmd=="o")
{
	cout << "\n\n";
	openmemo();
}
else{
	exit(EXIT_SUCCESS);
}*/

}

//*******************************************
//OPENMEMO FUNCTION
//*******************************************

void openmemo(){
cout << " Enter the invoice id : ";
long memoid;
cin >> memoid;
char path2[ MAX_PATH ];
if (SHGetFolderPathA( NULL, CSIDL_PERSONAL, NULL, 0, path2 ) != S_OK)
{
cout << “”;
}
else
{
cout << " ";
}
stringstream pathss2; //path string streamer
string s2;
pathss2 << path2;
pathss2 >> s2;
string billpath2=s2 + “\CashMemoBills”;
stringstream ss2;
ss2 << path2 << “\CashMemobills\bill” << memoid << “.cmb”;
string memofile = ss2.str();
FILE *file2;
int file1_exists;
const char * filename2=memofile.c_str();
file2=fopen(filename2,“r”);
if (file2==NULL){
cout << "\t\n No such invoices found with id " << memoid << “. Please try again…\n\n\t”;
header();
}
else{
cout << "\n\n ";
string output;
ifstream infile;
infile.open (memofile);
while (infile)
{
cout << output << endl;
getline(infile, output, ‘$’); //likely only need 1 of these
}
infile.close();

	cout << "\n\n Press any key to continue \n ";
	getch();
	system("cls");
	header();
  /*  if(exitcmd=="N" || exitcmd=="n")
    {
    	cout << "\n\n";
	    newmemo();
    }
    else if(exitcmd=="O" || exitcmd=="o")
    {
	    cout << "\n\n";
	    openmemo();
    }
    
	else{exit(EXIT_SUCCESS);}*/
}

}

void Del(){

cout<<"\n Enter invoice id to delete file records \n";
long memid;
cin>>memid;
char path3[ MAX_PATH ];

if(SHGetFolderPathA(NULL,CSIDL_PERSONAL,NULL,0,path3)!=S_OK)
{
cout<<"";
}
else{
cout<<" ";
}

stringstream pathss3;
string s3;
pathss3<<path3;
pathss3>>s3;

string billpath3=s3 + "\\CashMemoBills";
stringstream ss3;
ss3 << path3 << "\\CashMemobills\\bill" << memid << ".cmb";
string memofile = ss3.str();
FILE *file2;
int file1_exists;
const char * filename3=memofile.c_str();
file2=fopen(filename3,"r");
if (file2==NULL){
	cout << "\t\n No such invoices found with id " << memid << ". Please try again..\n\n\t";
	header();
}
else{
	cout << "\n\n ";
	string output;
    ifstream infile;
    infile.open (memofile);
    while (infile)
    {
      
	  delete(filename3);
    }
    infile.close();
	
	cout << "\n\n Press any key to continue \n ";
	getch();
	system("cls");
	header();
  /*  if(exitcmd=="N" || exitcmd=="n")
    {
    	cout << "\n\n";
	    newmemo();
    }
    else if(exitcmd=="O" || exitcmd=="o")
    {
	    cout << "\n\n";
	    openmemo();
    }
    
	else{exit(EXIT_SUCCESS);}*/
}

}

@sidstar

Please read this thread before posting your question: