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

Download pocket tank delux with 295 weapons free total 295 weapons version 1.6

Download Pocket Tanks Deluxe Full Version Free With 295 Weapons Pack | Size: 30MB UPDATED 2019 /19/april Description: Pocket Tanks is a 1-2 player computer game for Windows and Mac OS X, created by Blitwise Productions, developer of Super DX-Ball and Neon Wars. Adapted from Michael Welch's earlier Amiga game Scorched Tanks, this newer version features modified physics, dozens of weapons ranging from simple explosive shells to homing missiles, and the ability to move the tank. It supports several expansion packs. At the moment, players can have up to 295 different weapons total. Pocket Tanks is often abbreviated as PTanks. Have Fun! NOTE: FILE NAME IS SCRAMBLED FOR AVOIDING HARD DETECTION & FILE TAKEN DOWN . How to Play: Best with 2 players on the same computer at school or at work. UPDATED LINK https://mirr.re/d/u1Y https://nl26.seedr.cc/ff_get/447027537/ptd16.295.exe?st=lUp-PbRp4YOwToHIOGwStQ&e=1555747979 http://www.uploadmagnet.com/7gfzhbyfe...

python program to Print Starting Series OF Indian Mobile Number for a State or operator or both

import requests import urllib.request import time from bs4 import BeautifulSoup as bs import re url = ' https://en.wikipedia.org/wiki/Mobile_telephone_numbering_in_India' state_to_extract = "UE" #if set to None all state is considered telecom_to_extracted = None #if set to none all operator from particular city is extracted response = requests . get(url) print (response) soup = bs(response . text, "html.parser" ) one_a_tag = soup . findAll( 'tr' )[ 35 :] lst = [] for k in one_a_tag: s = k . findAll( 'td' ) limit = len (s) i = 0 while True : if i == limit: break no = s[i] . text i += 1 if i == limit: break operator = s[i] . text i += 1 if i == limit: break state = s[i] . text i += 1 if i == limit: break res = f "{no} {operator} {state}" if state_to_extract is None : if telecom_to_extracted is None : lst . append(no) elif telecom_to_e...

Streamlining Java Web Application Deployment with React WAR Generator

In the ever-evolving world of web development, managing builds and deployments can often be cumbersome and error-prone. Today, we're excited to introduce a tool designed to simplify and streamline this process: the React WAR Generator . What is the React WAR Generator? The React WAR Generator is a Python-based tool that automates the creation of WAR (Web Application Archive) files for Java web applications. It caters specifically to frontend projects built with React or similar frameworks, making it easier to package and deploy your web applications to a Tomcat server. Key Features Profile-Based Builds : With support for multiple profiles ( dev , test , prod , default ), you can build your application according to different environments and configurations. Version File Generation : Optionally generate a version file that integrates versioning information directly into your TypeScript files, ensuring your build versions are always up-to-date. Tomcat Deployment : Simplify your deploy...

python program to take nested list input ...(nested list addition ,substraction etc)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Mar 13 14:25:56 2018 @author: beast Note this program is for holding int value to list only """ def inmatrix (): matrixA = list () # intialize matrix as empty list try : row,col = [ int (j) for j in ( input ( "Enter the row and col " ) . split())] print (row,col) inp = "" except ValueError : print ( "Please Enter row and col seperated by space eg: 2 2" ) inmatrix() for i in range (row): for j in range (col): inp += (( input ( "Enter the number--->" )) + "," ) try : lst = [ int (a) for a in inp . split( "," ) if a != "" ] #delete int for making it to hold any data ...

hotkey-for-creating-new-folder-in-windows-explorer

New Folder Hotkey in Windows 7 Windows 7 natively includes a shortcut key combination to create a new folder: Ctrl+Shift+N Simply use this shortcut key anywhere in Windows Explorer, and a new folder will be instantly created: You can use the keyboard accelerator keys: Alt+F to bring up the file menu, and then <W> for the New menu, and then <F> for new folder. So your shortcut key sequence ends up being F+W+F with the Alt key held down Install bxNewFolder This freeware plugin uses F12 as the new folder hotkey, which unfortunately isn’t changeable. If you are using this in Windows XP, you’ll get the benefit of the new toolbar button that it adds, though. There’s no visible UI in Windows Vista, but it works perfectly. http://www.baxbex.com/products.html

30 Terrific Twitter Facts And Figures

Twitter has always suffered an image problem and is not usually taken very seriously by the general public. Its name doesn’t help with some people even saying that ‘Twitter is for twits’. Despite this glamor and brand problem this has not held back its growth after its humble origins and launch in 2006. Since then Twitter has gained popularity worldwide and is estimated to have 225 million users, generating 65 million tweets a day and handling over 800,000 search queries per day. It is sometimes described as the “SMS of the Internet” and its 140 character limit keeps the messages short and simple. Its attraction as a social web media platform is maybe in its simplicity and real time messaging that enables breaking news and information to hit the web instantly without filt30 Terrific Twitter Facts and Figures:- Twitter was created in March 2006 by Jack Dorsey and launched in July of that year. Twitter’s origins lie in a “day long brainstorming session” that was held by board...

Is aircel closed or closing down date... December 2017 news rumours

No, its nothing like that. There are some speculations amidst the Supreme court’s strict remarks but it doesn't seems like. They have also put in the application in the Apex Court for being heard their version as well and it looks like it will go through the rough patch as other party has put in the story as per their version and now they will get the chance to be heard. You will get to know that Aircel is operating and will keep on operating as it is on 3rd Feb, 2017 when the matter will be taken up in SC. Proof : 

3g what it is

Definition of 3G: 3G is the third generation of wireless technologies. It comes with enhancements over previous wireless technologies, like high-speed transmission, advanced multimedia access and global roaming. 3G is mostly used with mobile phones and handsets as a means to connect the phone to the Internet or other IP networks in order to make voice and video calls, to download and upload data and to surf the net. How is 3G Better?: 3G has the following enhancements over 2.5G and previous networks: Several times higher data speed; Enhanced audio and video streaming; Video-conferencing support; Web and WAP browsing at higher speeds; IPTV (TV through the Internet) support. 3G Technical Specifications: The transfer rate for 3G networks is between 128 and 144 kbps (kilobits per second) for devices that are moving fast and 384 kbps for slow ones(like for pedestrians). For fixed wireless LANs, the speed goes beyond 2 Mbps. 3G is a set of technologies and stand...