Fearless Leader wrote:Break down your problem into a series of simpler steps.
This way is inefficient but relatively simple.
1) Read in your text file into a big array of characters.
2) Parse out your text file into a list/array of lines.
3) Define a boolean flag and set it to false.
4) Traverse through your list/array of lines, character by character. If the flag is set to TRUE, make the character uppercase, if not, don't do anything to the character.
5) If you see "/*" set the flag to TRUE. When you see "*/" set the flag to FALSE.
6) Dump your list/array of lines to a new file.
I really dislike solutions like this. Use of fixed-length buffers is what got us into "buffer overflow exploit hell". Granted, nobody's going to try to exploit this program to break into a system... but this style of coding is a bad habit to get into.
bitvector wrote:The string literal issue is definitely valid, but I seriously hope he doesn't have to deal with that because it would add a few complications including escaped double quotes and strings broken across lines. Neither of these would be a large problem if it wasn't for the fact that the escape character in question (the backslash) can be specified as a trigraph (??/). That means you at least have to add a few more characters of lookahead.
I doubt that a CS instructor would be sadistic enough to require the handling of trigraphs on an assignment like this. How many people -- even experienced C developers -- are even aware of them?
OTOH handling quoted strings correctly is a pretty reasonable requirement IMO...