Back to problems

Remove All Comments from Source String (C++)

Algorithm · Microsoft · Medium

Problem: Strip Comments from Source Code (String Input / String Output) You receive source code as text, possibly containing line breaks. Delete every comment and return the remaining source text. Comment behavior: A single-line comment begins with // and continues through the rest of that line, but does not consume its newline. A multi-line comment opens with /* and closes at the first following */; it can cross line boundaries. When comments are removed, leave all…

Checking your access…