C++ Visual Studio 2013 Binary File IO

Feb 3rd, 2012
Studypool Tutor
Price: $10 USD

Tutor description

File Reading and Writing 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

Word Count: 291
Showing Page: 1/3
// CPPFileIO.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include #include #include #include #include #include using namespace std;bool isNumber(string word){for (auto it = word.cbegin(); it != word.cend(); ++it){if (!isdigit(*it))return false;}return true;}bool isAlphabet(string word){for (auto it = word.cbegin(); it != word.cend(); ++it){if (!isalpha(*it))return false;}return true;}void readMixed(){string buf;int theValue;vector numbers;vector alphas;vector tokens; // Create vector to hold our wordsstd::ifstream in("mixed.bin");if (in.is_open()){std::stringstream buffer;buffer << in.rdbuf();while (!buffer.eof()){while (buffer >> buf)token

Review from student

Studypool Student
" Super fast turn around time. Very impressed and will use Studypool again if I need a quick job. Communication was a bit tough but not unbearable. "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1829 tutors are online

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors