Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have this piece of c++ code ifstream myFile; myFile.open(argv[2]); while(true){//repeat while we will not reach till end of file char ch; myFile>>ch; if (myFile.eof())

I have this piece of c++ code

ifstream myFile; myFile.open(argv[2]); while(true){//repeat while we will not reach till end of file char ch; myFile>>ch; if (myFile.eof()) break; switch(ch){ case '+':cout<<"PLUS"< case '-':cout<<"MINUS"< case '*':cout<<"STAR"< case '/':cout<<"SLASH"< case '(':cout<<"LPAREN"< case ')':cout<<"RPAREN"< case ';':cout<<"SC"< case '=':cout<<"ASSIGN"< case '>':cout<<"GT"< case '<':cout<<"LT"< case ' ':break;

it reads a file that contains this < > * ( ) ; / / - +

LT

GT

STAR

LPAREN

RPAREN

SC

SLASH

SLASH

MINUS

PLUS

but now i need help with this if the file has this < > * ( ) ; / / - + "hello" + - the output would be

LT

GT

STAR

LPAREN

RPAREN

SC

SLASH

SLASH

MINUS

PLUS

SCONST (hello)

PLUS

MINUS

If this is is in the file, > * ( ) ; / - + "hello how are you " +

GT

STAR

LPAREN

RPAREN

SC

SLASH

MINUS

PLUS

SCONST (hello how are you)

PLUS

so basically when see a " in the file print out SCONST along with the string that was in it till the closing " so if the file has this "*-*-*"

it would print

SCONST (*-*-*)

i feel like adding a case '"': would be helpful please show the correct outputs to see that the code actaully works

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions

Question

=+a. Construct a Youden plot of this data.

Answered: 1 week ago

Question

3. Existing organizations and programs constrain behavior.

Answered: 1 week ago