Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

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.

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M91380075
  • Price:- $40

Guranteed 36 Hours Delivery, In Price:- $40

Have any Question?


Related Questions in C/C++

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As