Total members 11890 |It is currently Thu Apr 25, 2024 1:36 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     -  
 Read and write CSV file     -  
 File read by char     -  
 File write read     -  
 read file in matlab     -  
 Read Binary File in C++     -  
 Read and Write to file using ASP     -  
 javascript read file     -  
 read php file in asp and display it as html     -  
 Read XML file content using SAX and writing its as SQL     -  



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