473,320 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

printing file in reverse order

hi everyone,
im trying to solve this question

Write a C++ program that prints the file in reverse format character by character.

can anyone please tell me if im doing it correctly

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.    ifstream in ("file.txt");
  10.    in.seekg(0,ios::end);
  11.    int size=in.tellg();
  12.  
  13.       for (int j=1; j<=size; j++)
  14.         { in.seekg(-j, ios::end);
  15.           ch=in.get();
  16.           cout <<ch;
  17.          }
  18.  
  19.     in.close();
  20.     getch();
  21.     return 0;
  22. }
Thanks in advance
Dec 8 '06 #1
1 13156
hi everyone,
im trying to solve this question

Write a C++ program that prints the file in reverse format character by character.

can anyone please tell me if im doing it correctly

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.    ifstream in ("file.txt");
  10.    in.seekg(0,ios::end);
  11.    int size=in.tellg();
  12.  
  13.       for (int j=1; j<=size; j++)
  14.         { in.seekg(-j, ios::end);
  15.           ch=in.get();
  16.           cout <<ch;
  17.          }
  18.  
  19.     in.close();
  20.     getch();
  21.     return 0;
  22. }
Thanks in advance

I just had to add this in

Expand|Select|Wrap|Line Numbers
  1. char ch;
Sorry for posting such a silly thing

thanks
Dec 8 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: sahukar praveen | last post by:
Hello, I have a question. I try to print a ascii file in reverse order( bottom-top). Here is the logic. 1. Go to the botton of the file fseek(). move one character back to avoid the EOF. 2....
2
by: srp8982 | last post by:
hello, I need help (code) on following program ,its in c... 1)allow user to write file name in command line, read the file... 2) count characters, spaces and no. of lines in file given... 3)read...
4
by: Stupid48 | last post by:
I'm trying to do a simple task but can't seem to find a solution. How do I read lines from a text file backwards. i.e. I want to select the last 20 lines of a text file and display them in...
1
by: unknown198790 | last post by:
actually i created tftp server.server was created successfully but when i try to execute the following it say file not found tftp 192.168.0.1 tftp> put j.txt error code 1: file not found tftp...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.