Skip to main content

C++ Program to implement File Handling by using ifstream & ofstream -2

Write a paragraph (At least 2 lines of sentences) in a file. Read the same file in three different ways –
  i) Reverse the whole paragraph.
 ii) Line by Line Reverses the whole para.
iii) Break the paragraph into two equal halves. Reverse the second half of the paragraph.




#include
#include <fstream.h>
#include <conio.h>

void main(){
    char para[500], ln[80];
    int len, i, half;
    clrscr();

    cout<<"\n Enter a Paragraph (Quit by ^Z):-";
    cout<<"\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
    cin.getline(para, 500, '^Z');
    len = strlen(para);

    ofstream fout;
    fout.open("para.txt", ios::out);
    fout.write((char *) &para, len);
    fout.close();

    ifstream fin;
    cout<<"\n Reverse the Whole Paragraph:-";
    cout<<"\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~";
    fin.open("para.txt", ios::in);
    fin.read((char *) &para, sizeof(para));
    len = strlen(para);
    for(i=len; i>=0; i--)
        cout<    fin.close();
    getch();

    cout<<"\n Line by line Reverse the Whole Paragraph:-";
    cout<<"\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
    fin.open("para.txt", ios::in);
    while(fin){
        fin.getline(ln, 80);
        len = strlen(ln);
        for(i=len; i>=0; i--)
            cout<<ln[i];
        cout<<endl;
        }
    fin.close();
    getch();

    cout<<"\n Breaking The Para Into 2 halves and Reversing the 2nd Para:-";
    cout<<"\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
    fin.open("para.txt", ios::in);
    fin.read((char *) &para, sizeof(para));
    len = strlen(para);
    half = len / 2;
    for(i=0; i<=half; i++)
        cout<    for(i=len; i>half; i--)
        cout<    fin.close();
    getch();
    }

Comments

Popular posts from this blog

12 Tips to Maintain a Virus Free Computer

1. Email is one of the common ways by which your computer can catch a virus . So it is always recommended to stay away from SPAM. Open only those emails that has it’s origin from a trusted source such as those which comes from your contact list. If you are using your own private email host (other than gmail, yahoo, hotmail etc.) " then it is highly recommended that you use a good anti-spam software. And finally NEVER click on any links in the emails that comes from untrusted sources. 2. USB thumb/pen drives is another common way by which viruses spread rapidly." So it is always a good habit to perform a virus scan before copying any data onto your computer. NEVER double-click the pen drive to open it. Instead right-click on it and select the option “open”. This is a safe way to open a pen drive. 3. Be careful about using MS Outlook. Outlook is more susceptible to worms than other e-mail programs, unless you have efficient Anti-Virus programs running. Use Pegasus ...

USE any TRIAL SOFTWARE FOREVER WITHOUT SERIAL NUMBER

USE any TRIAL SOFTWARE FOREVER WITHOUT SERIAL NUMBER(most wanted trick) Run a trial software forever now with time stopper you can run a trial software forever no need to fetch for serial numbers,activation codes,patch just DOWNLOAD TIME STOPPER now open it install it click browse select the .exe of the software or file which you want to run forever now simply click create desktop icon and now delete all its existing shortcuts now have fun enjoying software for life time

what is LOREM ipsum and why do designers use it

What is Lorem Ipsum? Lorem Ipsum  is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now...

DOWNLOAD CODE BLOCKS 16.01 MINGW.SETUP .EXE 86.3 MB

Code::Blocks for Mac is a free C, C++ and Fortran IDE that has a custom build system and optional Make support. The application has been designed to be very extensible and fully configurable. Code::Blocks is an IDE packed full of all the features you will need. It has a consistent look, feel and operation across its supported platforms. It has been built around a plugin framework, therefore Code::Blocks can be extended with plugins. Support for any kind of functionality can be added by installing/coding a plugin. Key features include: Written in C++. No interpreted languages or proprietary libs needed.. Full plugin support. Multiple compiler support: GCC (MingW / GNU GCC), MSVC++, clang, Digital Mars, Borland C++ 5.5, and Open Watcom etc. Support for parallel builds. Imports Dev-C++ projects. Debugger with full breakpoints support. Cross-platform. Code::Blocks' interface is both customizable and extensible with Syntax highlighting, a tabbed interface, Class Br...

How to Put Google Adsense Below Post Title in Blogger?

Adsense is used by majority of expert bloggers for their website monetization because it is a cookie based contextual advertising system that shows targeted ads relevant to the content and reader. As bloggers are paid on per click basis, they try various ad placements on the blog to  increase the revenue  and get maximum clicks on the ad units. Well, on some blogs, you might have seen Adsense ad units placed below the post title. Do you know why? It is because the area just below the post title gets the most exposure and is the best place to put AdSense ad units to increase  Click Through Rate (CTR). Even though ads below post title work like a charm but this doesn’t mean that it will work for you as well. If you want to find out the best AdSense ads placement for your blog, try experimenting by placing ads at various locations such as header, sidebar, footer, etc. You can try other  blog monetization methods  as well to effectively monetize y...

5 Best Popular Posts Widgets For Blogger

Adding the Popular Posts Widget for Blogger Just click on your blog title, access the "Layout" menu, click "Add a Gadget" and choose "Popular Posts". A window will appear asking you to configure the widget by choosing which posts you'll feature (e.g. those that were most viewed in the past 7 days or 30 days or from the beginning of your blog). You'll also be asked to choose how many posts you'll feature in your Popular Posts section and select if you'll show the post title only or along with the image thumbnail and/or the snippet. (Remember that each widget style has different requirements, so follow the styles and instructions carefully to find out if you need the snippet and image thumbnail or not). Popular Posts Style 1 - Box within a box This is an interesting widget style since it uses your snippet and image thumbnail in a unique way. Your snippet is written in opaque text and placed in a small transparent box. This, in turn, ...

C++ Program to find out the Prime number's By sieve Method

NOTE : YOU CAN DOWNLOAD EXE FILE HERE: SIEVE.EXE SORUCE CODE (RTF): source.cpp click here   1  #include <iostream>  2  #include <conio.h>  3  using namespace std ;  4  int main ()  5   6  {  7   8  int number , n = 2 ;  9  cout << "Program to find out Prime number by sieve method\n\n\a" ; 10  11  cout << "Enter upto which number you want to find out the prime number\n" ; 12  cin >> number ; 13  int arr [ number ]; 14  for ( int i = 0 ; i < number ; i ++) 15  arr [ i ]= i + 1 ; 16  cout << "  Original number:\n" ; 17  18  for ( int i = 0 ; i < number ; i ++) 19  { 20  21  22      cout << arr [ i ]<< "\t\a" ; 23  24  } 25  while (( n * n )< number )  // while n 2  ...

Windows 10 1703 Fall Creator update/upgrage brings NEW UI ... the fluent Ui

Microsoft is planning to implement these subtle design changes gradually. Some are already available in new updates to existing Windows 10 apps, and more will start to appear in Windows itself as Microsoft updates the operating system with the Fall Creators Update and future updates. "It's going to be a journey," says Microsoft director Aaron Woodman, noting that these design changes will appear over time in Windows and other products. On stage at Build today, Microsoft's Joe Belfiore demonstrated a number of Fluent Design changes. "You're going to see Fluent Design show up in the Windows shell, in our apps, and across devices," explains Joe Belfiore. Microsoft is focusing on light, depth, motion, material, and scale for its Fluent Design, with subtle changes that make the design feel like it's moving during interactions in Windows. An inking demo showed how Microsoft is bringing the pen experience across the entirety of Windows, allowing...

FIXED: Feedjit gadgets no longer work on my blog!!! help

well if your feedjit tracker is not working than you can easily fix this... goto blogger.com Go to  Dashboard -> Settings And set  HTTPS Redirect  to  No The gadgets will work now for  http ://yourblog.blogspot.com They won't for  https ://yourblog.blogspot.com because their connection isn't secure. this is not a permanent fix ... the gadget developers will have to make their gadgets https ready before Blogger will (if at all) become https only.

How to Detect Anonymous IP Addresses

Proxy Detection Serviceshttp = So in order to stop such online frauds, Proxy Detection has become a critical component. Today most companies, credit card merchants and websites that deal with e-commerce transactions make use of Proxy Detection Services like MaxMind and FraudLabs to detect the usage of proxy or spoofed IP from users participating online. Proxy Detection web services allow instant detection of anonymous IP addresses. Even though the use of proxy address by users is not a direct indication of fraudulent behaviour, it can often indicate the intention of the user to hide his or her real IP. In fact, some of the most used ISPs like AOL and MSN are forms of proxies and are used by both good and bad consumers. How Proxy Detection Works? Proxy detection services often rely on IP addresses to determine whether or not the IP is a proxy. Merchants can obtain the IP address of the users from the HTTP header on the order that comes into their website . This IP addr...