Below is my code:
string ckeywords = File.ReadAllText("E:\\ckeywords.csv");
string[] clines = File.ReadAllLines("E:\\cprogram\\cpro\\bubblesort.c");
string letters="";
foreach(string line in clines)
{
char[] c = line.ToCharArray();
foreach(char i in c)
{
if (i == '/' || i == '"')
{
break;
}
else
{
letters = letters + i;
}
}
}
letters = Regex.Replace(letters, @"[^a-zA-Z ]+", " ");
List<string> listofc = letters.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
List<string> listofcsv = ckeywords.Split(new char[] { ',', '\t', '\n', ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()).ToList();
List<string> Commonlist = listofcsv.Intersect(listofc).ToList();
With this if
condition, I am able to ignore reading contents of single line comment and contents between ("").
I need to ignore reading contents of multi line comments. Which condition should I use? Suppose my .c file is having this line of comment so with above code I don't know how to start iterating from /* to */ and to ignore the contents in between.
/*printf("Sorted list in ascending order:\n");
for ( c = 0 ; c < n ; c++ ) printf("%d\n", array[c]);*/