Moduri diferite de a citi date dintr-un fisier text
#include<iostream>
#include<fstream>
using namespace std;
int main()
{int a,b,c,x[100],nr=0;
char s[100],s1[100],c1,c2;
ifstream fin("date.in");//
if(fin==NULL)
cout<<"Eroare";
/*
// citire numere
while(fin>>a)
{cout<<a<<";";
nr++;}
cout<<endl<<"Nr elemente "<<nr<<endl;
// citire siruri de caractere fara spatii
fin>>s;
while(!fin.eof())
{cout<<s<<";";nr++;fin>>s;}
cout<<endl<<"Nr de siruri(cuvinte, pana la spatiu):"<<nr<<endl;
//citim caractere, dar nu si cele albe(c1 este de tip char, caracter)
fin>>c1;
while(!fin.eof())
{cout<<c1<<";";nr++;fin>>c1;}
cout<<endl<<"Nr de caracrete(fara spatii albe):"<<nr<<endl;
//se citesc cuvinte(pana la spatiu)
while(fin>>s)
{cout<<s<<";";nr++;}
cout<<endl<<"NR de cuvinte: "<<nr<<endl;
//se citesc caractere, dar fara caractere albe
while(fin>>c1)
{cout<<c1<<";";nr++;}
cout<<endl<<"NR de caractere(fara cele albe): "<<nr<<endl;
//se citesc toate caracterele, inclusiv cele albe(spatiu si enter)
while(fin.get(c1))
{cout<<c1<<"|";nr++;}
cout<<endl<<"nr de caractere total="<<nr<<endl;
*/
//7.
while((c1=fin.get()) != EOF)
{cout<<c1<<";"; nr++;}
}