Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

while(true){//repeat while we will not reach till end of file char ch; myFile>>ch; if (myFile.eof()) break; switch(ch){ case '+':cout <

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"<':cout<<"GT"<

I have this c++ code

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

LT

GT

STAR

LPAREN

RPAREN

SC

SLASH

SLASH

MINUS

PLUS

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 the file has this, > * ( ) ; / - + "hello how are you " +

the outbut would be this

GT

STAR

LPAREN

RPAREN

SC

SLASH

MINUS

PLUS

SCONST (hello how are you)

PLUS

Now i need help with this if i file containes this ;

"hello this

broken"

it would print this

Error on line 1 ("hello this

)

so if a file contained this

+ "hello this is ok"

"this is not

ok"

it woukd print

PLUS

SCONST (hello this is ok)

Error on line 2 ("this is not

)

so basically if the words in the quotes are broken into different lines it sould return the error. If it is not broken up it will return SCONST along with the string, but that is already handled in the provided code. i need help with the error case.

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

Step: 3

blur-text-image

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