Question: How can I write this java in C++? File file = new File( /wholeNumber.txt); File file1 = new File( /fraction.txt); if(!file.exists()) file.createNewFile(); if(!file1.exists()) file1.createNewFile(); PrintWriter

How can I write this java in C++?

File file = new File("<>/wholeNumber.txt"); File file1 = new File("<>/fraction.txt"); if(!file.exists())

file.createNewFile();

if(!file1.exists())

file1.createNewFile();

PrintWriter pw = null;

//Writing Whole Numbers

pw = new PrintWriter(file);

for(Integer in:wholeList)

{

pw.write(String.valueOf(in));

pw.println();

}

pw.flush();

pw.close();

//Writing Fraction Numbers

pw = new PrintWriter(file1);

for(Double db:fractionList)

{

pw.write(String.valueOf(db));

pw.println();

}

pw.flush();

pw.close();

}

//end of 1st try

catch (FileNotFoundException e)

{

// TODO Auto-generated catch block

e.printStackTrace();

}

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!