Skip to content

Instantly share code, notes, and snippets.

/* The following code romves all C-language comments and empty lines. */
for(uint64_t i = 0; i < strlen(src); i++) {
// One line comment:
if((src[i] == '/') && (src[i+1] == '/')) {
for( ;src[i] != '\n'; i++) {} // Comment ends to a newline - search for the end.
for( ;src[i+1] == '\n'; i++) {} // Remove extra trailing newlines.
continue;
}
// Block comment: