#include<iostream>
#include<fstream>
using namespace std;
void main()
{
char word[5];
ifstream file;
file.open("abcd.txt",ios::in);
if(file)
{
while(file>>word)
{
cout<<word<<" ";
}
}
else
cout<<"file not opened";
}
CONTENT OF THE FILE abcd.txt:
pineapple orange seventeen computer
The output which i get is:
pineapple orange seventeen computer
I have mention the array size as 5 but the extraction(>>) operator read words with size more than five into the array (but the array size is five!).How do this happens?.How is this possible?
The output which i expected is:
pinea orang seven compu