Fișiere

#include <iostream>
#include <fstream>
int main()
{
    std::ofstream fisier ("c:/primul.txt");
    fisier << "Hello World!\n";
    fisier.close();
}


#include <iostream>     
#include <fstream>      

int main() {
   
    std::ifstream fisier("aldoilea.txt");     
    char c;
    while (fisier.get(c))          
        std::cout << c;
    fisier.close();               
}


#include <iostream>     
#include <fstream>      

int main() {
   
    std::ifstream fisier("numere.txt");     
    int c;
    while (fisier>>c)          
        std::cout << c;
    fisier.close();               
}


#include <iostream>     
#include <fstream>      

int main() {
   
    std::ofstream fisier("numere1.txt");     
    for (int i = 0; i < 10; i++) {
        fisier << i;
    }
    fisier.close();               
}