Question

I need to complete a fill-in-the-blank C++ program using DEV C++, code needs to stick to program...

************************* proverb.txt. **********************************
Now Is The Time fOr All GoOd Men to come to the aid of their Family

*************************************************************************

the sample run is as follows:

Sample Run:
The read position is currently at byte 0
Enter an offset from the current position: 4
The character read is I
If you would like to input another offset enter a Y y
The read position is currently at byte 5
Enter an offset from the current position: 2
The character read is T
If you would like to input another offset enter a Y y
The read position is currently at byte 8

[code]


#include <iostream>
#include <fstream>
#include <cctype>
using namespace std;


int main()
{
fstream inFile("proverb.txt", ios::in);
long offset;
char ch;
char more;


do
{
// Fill in the code to write to the screen
// the current read position (with label)
cout << "Enter an offset from the current read position: ";
cin >> offset;
// Fill in the code to move the read position “offset” bytes
// from the CURRENT read position.
// Fill in the code to get one byte of information from the file
// and place it in the variable "ch".
cout << "The character read is " << ch << endl;
cout << "If you would like to input another offset enter a Y"
<< endl;
cin >> more;
// Fill in the code to clear the eof flag.
} while (toupper(more) == 'Y');
inFile.close();
return 0;
}


[/code]

0 0
Add a comment Improve this question Transcribed image text
Answer #1
01 #include <iostream>
02  
03 #include <fstream>
04  
05 #include <cctype>
06  
07 using namespace std;
08  
09 int main()
10  
11 {
12  
13 fstream inFile("proverb.txt", ios::in);
Answer #2

#include <iostream>

#include <fstream>

#include <cctype>

using namespace std;

 

int main()

{

fstream inFile("proverb.txt", ios::in);

long offset;

char ch;

char more;

 

do

{

// Fill in the code to write to the screen

cout << "The read position is currently at byte " << inFile.tellg() << endl;

// the current read position (with label)

 

cout << "Enter an offset from the current read position: ";

cin >> offset;

 

//Fill in the code to move the read position “offset” bytes

inFile.seekg(offset, ios::cur);

//from the CURRENT read position.

 

//Fill in the code to get one byte of information from the file

ch = inFile.get();

//and place it in the variable "ch".

 

cout << "The character read is " << ch << endl;

cout << "If you would like to input another offset enter a Y"

<< endl;

cin >> more;

 

inFile.clear();

// Fill in the code to clear the eof flag.

 

} while (toupper(more) == 'Y');

 

inFile.close();

 

return 0;

}

Know the answer?
Add Answer to:
I need to complete a fill-in-the-blank C++ program using DEV C++, code needs to stick to program...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Retrieve program randomAccess.cpp and the data file proverb.txt from the Lab 14 folder. The code is as follows: #include...

    Retrieve program randomAccess.cpp and the data file proverb.txt from the Lab 14 folder. The code is as follows: #include <iostream> #include <fstream> #include <cctype> using namespace std; 327 int main() { fstream inFile("proverb.txt", ios::in); long offset; char ch; char more; do { // Fill in the code to write to the screen // the current read position (with label) cout << "Enter an offset from the current read position: "; cin >> offset; // Fill in the code to move...

  • This is for a C++ program: I'm almost done with this program, I just need to...

    This is for a C++ program: I'm almost done with this program, I just need to implement a bool function that will ask the user if they want to repeat the read_course function. I can't seem to get it right, the instructions suggest a do.. while loop in the main function. here is my code #include <iostream> #include <cstring> #include <cctype> using namespace std; const int SIZE = 100; void read_name(char first[], char last[]); void read_course(int & crn, char des[],...

  • C++ Programming - Design Process I need to create a flow chart based on the program...

    C++ Programming - Design Process I need to create a flow chart based on the program I have created. I am very inexperienced with creating this design and your help will be much appreciated. My program takes a string of random letters and puts them them order. Our teacher gave us specific functions to use. Here is the code: //list of all the header files #include <iomanip> #include <iostream> #include <algorithm> #include <string> using namespace std; //Here are the Function...

  • C++ problem where should I do overflow part? in this code do not write a new...

    C++ problem where should I do overflow part? in this code do not write a new code for me please /////////////////// // this program read two number from the user // and display the sum of the number #include <iostream> #include <string> using namespace std; const int MAX_DIGITS = 10; //10 digits void input_number(char num[MAX_DIGITS]); void output_number(char num[MAX_DIGITS]); void add(char num1[MAX_DIGITS], char num2[MAX_DIGITS], char result[MAX_DIGITS], int &base); int main() { // declare the array = {'0'} char num1[MAX_DIGITS] ={'0'}; char...

  • #include <fstream> #include <iostream> #include <cstdlib> using namespace std; // Place charcnt prototype (declaration) here int...

    #include <fstream> #include <iostream> #include <cstdlib> using namespace std; // Place charcnt prototype (declaration) here int charcnt(string filename, char ch); int main() { string filename; char ch; int chant = 0; cout << "Enter the name of the input file: "; cin >> filename; cout << endl; cout << "Enter a character: "; cin.ignore(); // ignores newline left in stream after previous input statement cin.get(ch); cout << endl; chcnt = charcnt(filename, ch); cout << "# of " «< ch« "'S:...

  • Write a simple telephone directory program in C++ that looks up phone numbers in a file...

    Write a simple telephone directory program in C++ that looks up phone numbers in a file containing a list of names and phone numbers. The user should be prompted to enter a first name and last name, and the program then outputs the corresponding number, or indicates that the name isn't in the directory. After each lookup, the program should ask the user whether they want to look up another number, and then either repeat the process or exit the...

  • Using C++ Use the below program. Fill in the code for the 2 functions. The expected...

    Using C++ Use the below program. Fill in the code for the 2 functions. The expected output should be: The:fox:jumps:over:the:fence.: The:fox:jumps:over:the:fence.: The:fox:jumps:over:the:fence.: The:fox:jumps:over:the:fence.: #include #include #include using namespace std; //Assume a line is less than 256 //Prints the characters in the string str1 from beginIndex //and inclusing endIndex void printSubString( const char* str1 , int beginIndex, int endIndex ) { } void printWordsInAString( const char* str1 ) { } int main() { char str1[] = "The fox jumps over the...

  • C++ Check Book Program I need to have a checkbook program that uses the following items....

    C++ Check Book Program I need to have a checkbook program that uses the following items. My code that I have appears below. 1) Math operations using built-in math functions 2) Class type in a separate .h file with member functions (accessor functions, get, set, show, display find, etc). There needs to be an overloaded function base/derived classes or a template. 3) Binary File #include <iostream> using namespace std; int main() {     double checking,savings;     cout<<"Enter the initial checking...

  • Use C++ #include <iostream> #include <stdlib.h> #include <stdio.h> #include <cstring> using namespace std; /I Copy n...

    Use C++ #include <iostream> #include <stdlib.h> #include <stdio.h> #include <cstring> using namespace std; /I Copy n characters from the source to the destination. 3 void mystrncpy( ???) 25 26 27 28 29 11- 30 Find the first occurrance of char acter c within a string. 32 ??? mystrchr???) 34 35 36 37 38 39 / Find the last occurrance of character c within a string. 40 II 41 ??? mystrrchr ???) 42 43 45 int main() char userInput[ 81]; char...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT