Hi beginner_99,
Note that the suggestions you have received work for your sample input (and any other input that has no comments or exactly one complete comment on each line). The suggestions will not work with the following "code":
/*
** Multi-line comment.
*/
/* Multiple comments... */ code; /* ... on one line. */
Are either of these limitations a problem for the real data you will be processing?