Total members 11864 |It is currently Thu Dec 09, 2021 6:10 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Code:
#include <fstream>
const char *FILENAME "FILE.txt";


    
int main() {
        
//create output object associated w/ file
        
ofstream fout(FILENAME);
        
cout << "Enter your secret password: ";
        
char str[60];
        
cin >> str;
        
//write to file
        
fout << "This is your secret password. Don't give it to anyone!\n";
        
fout << str;
        
//close file
        
fout.close();
        
cout << endl;
        
ifstream fin(FILENAME);
        
char ch;
        while (
fin.get(ch))
            
cout << ch;
        
fin.close();    
        return 
0;


this code allow you to read and write from file in C++ . :wink:



_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 95
Have thanks: 2 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : read from file in C++
 Read csv file     -  
 File read by char     -  
 File write read     -  
 read file in matlab     -  
 Read and Write to file using ASP     -  
 Read Binary File in C++     -  
 javascript read file     -  
 Read and write CSV file     -  
 Read Arabic text from file     -  
 How to read and write to CSV file from python     -  



Topic Tags

C++ Files and I/O






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com