Question: i have no idea what to do here update: the second else if in the while loop is supposed to contain inMultiCmt = false inside
Notice that the multi-line comment closing characters are still being printed. 5. Chasing Bugs If you look back at the code, you'll see that when you encounter the end of a multi-line comment, you set the inMultiCmt flag to false, but then go ahead and print the next two characters, which seems to be the problem. Try this for a fix. Whenever you stop a multi-line comment (set inMultiCmt to false), simply consume those two characters using cin.get(ch). (This needs to replace the second else-if in the pseudocode.) Now, when you run the tests I've provided, you'll pass more that 70%. char ch; bool inSingleCmt false; bool inultiCmt = false; bool inString false; while(cin.get(ch)) inSingleCmt false;3 inString = false;} cin.get(ch); else if(inString && ch-...'){ else if inMultiCmt && ch& cin. peek else if(linString&& linSingleCmt && linMultiCmt) if(ch else if(ch- else if(ch- inString true;3 B& cin. peek()- '*'){ nMulticmt = true;} B& cin . peek()- '/'){ inSingleCmt = true;} cout.put(ch)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
