Initially I am keeping it simple. I amonly checking comments between /* and */. If found true, count the caharcters between them & replace with blanks. That's my simple logic. Beats me , why it is not working?
Code:
#include <stdio.h>
int main(void)
{
int c =0;
int i =0;
int m =0;
int s[1000];
int in_quotes = 0;
for (i=0; i < 999 && (c=getchar())!= EOF; ++i)
{
s[i] = c;
if (in_quotes == 0)
{
if (s[i] == '/' && s[i+1] == '*')
{
i = i+2;
in_quotes = 1;
}
if (s[i] == '*' && s[i+1] == '/')
{
i =i+2;
in_quotes = 0;
}
if (in_quotes == 1)
{
i++;
for (m = 0;m <=i; m++)
{
s[m] = ' ';
}
}
printf ("%s", s);
}
else
{
printf ("%c", s[i]);
}
}
}