Task:
You program must process all input from standard input (i.e., std::cin) and write all output to standard output (i.e., std::cout). This must be done in C++.
Edit: You can consider the input as a string
Clarifications:
#include
#include // for std::noskipws
using namespace std;
int main()
{
bool is_within_double_quotes = false;
char byte;
while (cin >> noskipws >> byte)
{
// NOTE: output your bytes with cout.put(byte);
// or, cout << byte; (if byte is a char)
// or, cout << static_cast(byte); (if byte is not a char)
#error "Write code in here to process the input and write output to std::cout."
}
}
Sample Program Input File:
Consider this input file a1-input.dat:
$ cat a1-input.dat This -is' ?some? text. "This i-s 'so'.me text?" "a.b-c'd?z"A.B-C'D?Z'0.1-2"3?9'4.5-6'7?"aA.bB-cC'dD?zZ $
Sample Program Run:
This is a sample program run:
$ ./a.out
--------------------------------------main.cpp-------------------------------
#include <iostream>
#include <iomanip> // header
for noskipws
#include <fstream> // for
reading files
using namespace std;
int main()
{
char result;
ifstream fin("a1-input.dat");
bool is_within_double_quotes = false;
char byte;
while (fin >> noskipws >> byte)
{
// check if current character is
double quote
if(byte == '"')
{
// toggle the
flag to indicate text between double quotes
is_within_double_quotes = !is_within_double_quotes;
}
// if current character is not
inside double quotes, process it
if
(!is_within_double_quotes)
{
switch
(byte)
{
case '.':
case '?':
case ',':
case '\'':
case '-':
result = ' ';
break;
default:
result = byte;
break;
}
}
// else print the character as
is
else
{
result =
byte;
}
cout << result;
}
}
----------------------------------------output-----------------------------------------


Task: if the character read in is a '.' (dot), ',' (comma), '?' (question mark), '-'...
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...
Computer Science C++ Help, here's the question that needs to be answered (TASK D): Task D. Decryption Implement two decryption functions corresponding to the above ciphers. When decrypting ciphertext, ensure that the produced decrypted string is equal to the original plaintext: decryptCaesar(ciphertext, rshift) == plaintext decryptVigenere(ciphertext, keyword) == plaintext Write a program decryption.cpp that uses the above functions to demonstrate encryption and decryption for both ciphers. It should first ask the user to input plaintext, then ask for a right...
************************* 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 0Enter an offset from the current position: 4The character read is IIf you would like to input another offset enter a Y yThe read position is currently at byte 5Enter an offset from the current position: 2The character read is TIf you would like to input another offset enter a...
C++ Create a program that finds the dot product of two vectors. I'm currently trying to display the dot product by calling the dotProduct member function however I am confused as to how to do this. What would be the proper way to display the dot product? I don't believe my dotProduct member function is set up correctly to access the proper data. Feel free to modify the dotProduct member function to allow for it to work with the other...
#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:...
Complete a partially written C++ program that includes a function that return a value. The program is a simple calculator that prompts the user of 2 number and an operation (+, -, * or, /). The two number and the operator are passed to the function where the appropriate arithmetic operation is performed. The result is return to the main function () where the arithmetic operation and result are displayed. For example 3 * 4 = 12 The source code...
java find and replace code pls help me We write code that can find and replace in a given text file. The code you write should take the parameters as command line arguments: java FindReplace -i <input file> -f "<find-string>" -r "<replace-string> -o <output file> *question mark(?) can be used instead of any character. "?al" string an be sal ,kal,val *In addition, a certain set of characters can be given in brackets.( "kng[a,b,f,d,s]ne" string an be kngane,hngbne,kangfne,kangdne,kangsne So, all you...
Hi, it's C++ question. Only can use <iostream> and <fstream>libraries Please help me, thanks Question Description: For this project you will write a program to: a) read-in the 10 first names from a file (the file is a priori given to have exactly 10 entries, of a maximum length of 8 letters each) into a 2-dimensional character array, b) output the names to the terminal with each one preceded by a number indicating its original order in the list, c)...
Task The task for this assignment is to have the following user-defined data type: struct rgb { unsigned char red; unsigned char green; unsigned char blue; }; be able to be: read in from a stream (e.g., std::cin), i.e., write: std::istream& operator >>(std::istream& is, rgb& colour); (see below) written out to a stream (e.g., std::cout), i.e., write: std::ostream& operator <<(std::ostream& os, rgb const& colour); (see below) stored in a container, e.g., std::vector<rgb>, std::array<rgb,16>; (see below) processed via algorithms (and other...
I need help finding what is wrong with this code, it is for a CS course I am taking which codes in C (I am using XCode on Mac to code). This is the assignment: "Write a program that performs character processing on 10 characters read in from a file, and writes the results to output files. The program should read from “input.dat”. The program should write the ASCII values of the characters to “output_ascii.dat”. The program should print statistics...