Data File Handling - Solution (SD/4/A/293)

Write function definition for WORD4CHAR() in C++ to read the content of a text file "FUNNY.TXT", and display all those words, which has four characters to it.

Solution:

Data File Handling - Text File (SD/4/A/293)


void WORD4CHAR()
{
char word[80];
ifstream fin("FUNNY.TXT");
while(!fin.eof())
{
fin>>word;
if(strlen(word)==4)
{
cout<<word<<" ";
}
}
fin.close();
}






No comments

Post your comments

Powered by Blogger.