Archive for the ‘C++’ Category

Write a function to count number of words in a text file named “OUT.TXT”

February 16th, 2013, posted in C++
Share
void countwords()
{
	ifstream fin;
	fin.open("out.txt");
	char word[30];
	int count=0;
	while(!fin.eof())
	{
		fin>>word;
		count++;
	}
	cout<<"Number of words in file are "<<count;
	fin.close();
}
Share

Write a function to count number of words in a text file named "OUT.TXT"

February 16th, 2013, posted in C++
Share
void countwords()
{
	ifstream fin;
	fin.open("out.txt");
	char word[30];
	int count=0;
	while(!fin.eof())
	{
		fin>>word;
		count++;
	}
	cout<<"Number of words in file are "<<count;
	fin.close();
}
Share

Write a C++ program to write number 1 to 100 in a data file NOTES.TXT

February 12th, 2013, posted in C++
Share
#include<fstream.h>

int main()
{
	ofstream fout;
	fout.open("NOTES.TXT");
	for(int i=1;i<=100;i++)
		fout<<i<<endl;
	fout.close();
	return 0;
}
Share