C++ program to print file contents in reverse order

C++ program to print the contents of any text file in reverse order. This program print the reverse of each and every word available in that text file.

This program was developed in Windows 10 using Dev C++ IDE. Here is the source code.

/*	program to display the contents of any text file in reverse order.
	made by		: rakesh kumar
*/

#include
#include
#include
using namespace std;
int main()
{
	ifstream fin("file_reverse_order.cpp");
	char ch;
	int j=0;
	char str[100];
	while(!fin.eof())
	 {
	 	fin.get(ch);
	 	if(ch==' '|| ch=='\n'||ch=='\r'||ch=='\t'||ch==',')
	 	   {
			str[j]='\0';cout<<strrev(str);cout<<ch;j=0;}
		else
		   	str[j++]=ch;
	 }   
	fin.close();
	return 0;
}

The output of the program is as follows

C++ program to print file contents in reverse order

%d bloggers like this: