0% found this document useful (0 votes)
20 views

Converter

The document describes converting a C file to C++ by opening the C file for reading and writing, reading in lines, replacing C-specific print statements with C++ cout statements, and writing the modified lines to a new C++ file.

Uploaded by

junaid khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Converter

The document describes converting a C file to C++ by opening the C file for reading and writing, reading in lines, replacing C-specific print statements with C++ cout statements, and writing the modified lines to a new C++ file.

Uploaded by

junaid khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<iostream>

#include<fstream>
#include<string>
using namespace std;

int main()
{
string arr[500];
ifstream getCfile;
ofstream C_to_Cppfile;
getCfile.open ("Cfile.c", std::fstream::in | std::fstream::out |
std::fstream::app);
C_to_Cppfile.open("C_to_Cppfile.cpp");
//getCfile<<"Writing this file to a C++ File"<<endl;
if(getCfile.is_open()){
for(int i=0; i<10; i++)
{
getCfile>>arr[i];
cout<<arr[i]<<endl;
if(arr[i]=="printf(\"Hello")
arr[i]="cout<<\"Hello";
else if(arr[i]=="World\");")
arr[i]="World\";";
}
}
for(int i=0; i<10; i++)
C_to_Cppfile<<arr[i];
getCfile.close();
C_to_Cppfile.close();
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy