As the title suggests, I need to extract comments from a C file, which are usually marked with " /* This is a comment */ ". It seems to me that I need to calculate first at what position is the / and then ask it if on the very next position to the / operand is the *, if it is then I need check where is the next * and if / operand is immediately next to it. At last I need to take everything between values that the first and second * have.
But I don't know how to write that in code.
I've forgot to mention, this was supposed to be done in c++.
Here is C code to remove all comments I wrote back in high school. Be wary, that it is not an example of good style and might contain bugs (Escaped characters and quotes in character literals are sure ones)
You can look how comment detection was implemented and just reverse process to remove everything but the comments.