Writing out the results to the console

Assignment Help C/C++ Programming
Reference no: EM13810120

This assignment consists of reading three files and writing out the results to the console. The three files can be found on Moodle: text.bin, bin_data.bin, and mixed.bin.

1) Reading text from a file

You are to open the file "text.bin" for reading. It contains a single line of text "Mary had a little lamb". You are to read this file, read the words, then write them to the console in reverse order. The output should read

"lamb little a had Mary".

Hint: Store the words in an array as you read them.

2) Reading binary data from a file

You are to open the file "bin_data.bin" for reading. It contains binary data written using the following data format:

struct binary {int a; float b; char letters[6];}

That is, there are three records in the array. Each record contains one int, one float, and 6 letters. You are to read the data and output it to the console. The output should look like (depending on formatting):

3 3.14 pi 2 1.414 sqrt 42 42.0 towel

Hint: Create a buffer of type binary and read the data into it. Then you can access it by bufferName.a, bufferName.b, bufferName.letters. Read and output one buffer full at a time until you reach the end of the file.

3) Reading and parsing mixed data

You are to open the file "mixed.bin" for reading. It contains ascii data that is a mixture of words and integers with spaces between each item. There are a total of four lines in the file, the fourth line contains "00". You should read a line of data, then break it into words and numbers, saving them in a string array and an integer array. You can ignore any spaces. When you are done reading the file, you should write out the saved data. The output should look like:

Horse House Elephant Dog Car Cat Mouse Rat Cow Pig Chicken

36 32 1 2 4 47 19 19 11 0

Hint: Read each line into a buffer. Then walk down the buffer one character at a time. If the character is a letter, then extract a word. If the character is a digit, then extract a number. If it is a space, then increment the index by one.

Reference no: EM13810120

Questions Cloud

Discuss elite democrats or popular democrats : Based on the published information on the websites, discuss whether individuals who associate with this group should be classified as elite democrats or popular democrats.
Discuss about peacekeeping : PEACEKEEPING
Project and evaluate the project success : In this activity, you synthesize the lessons you learned in completing your project and evaluate the project's success. Address the following questions in a separate document:
Write a response paper about essay dorian grays bad decision : Write a response paper about the essay "Dorian Gray's Bad Decisions".
Writing out the results to the console : This assignment consists of reading three files and writing out the results to the console. The three files can be found on Moodle: text.bin, bin_data.bin, and mixed.bin
Write response paper about the essay morals vs aestheticism : Write a response paper about the essay "Morals Vs. Aestheticism".
Assignment on mergers and acquisitions : Use the Internet to research a publicly traded company in the United States that has undergone a merger or acquisition within the last three (3) years. Take note of the circumstances surrounding the merger or acquisition.
Write a loop that will step through the array : Write a loop that will step through the array you defined in question 1, displaying the contents of each element that doesn't contain a NULL pointer
The role of the federal reserve : A specific piece of legislation relating to business regulation or taxation. The "party platform" of either the Republican Party or the Democratic Party or both

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd