All pastes #392953 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-03-13 05:54 UTC
rendered paste body
#include <stdio.h>

/* remove comments from C source */
main()
{
        char c, lc;
        int incom;

        while ((c = getchar()) != EOF) {
                if (incom == 1) {
                        if (lc == '*' && c == '/') {
                                incom = 0;
                        }
                }
                else if (c == '/') {

                } /* eh? */
                else if (lc == '/' && c == '*') {
                        incom = 1;
                }
        /*      else if (lc == '/' && c != '*') {
                        printf("HMMM");
                } */
                else if (lc == '/' && incom == 0 && c != '*') {
                        printf("%c%c", lc, c);
                }
                else {
                        printf("%c", c);
                }
                lc = c;
        }
}