Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!