forked from SarthakShah001/Compiler2K23
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_comments.c
More file actions
51 lines (49 loc) · 1.33 KB
/
remove_comments.c
File metadata and controls
51 lines (49 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
***** Group No. - 9 *****
Name : Sarthak Shah ID : 2020A7PS0092P
Name : Siddharth Khandelwal ID : 2020A7PS0098P
Name : Archaj Jain ID : 2020A7PS0072P
Name : BhanuPratap Singh Rathore ID : 2020A7PS1675P
Name : Rishi Rakesh Shrivastava ID : 2020A7PS0108P
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "removeComments.h"
void removeComments(char *testCaseFile, char *cleanFile)
{
int j = 0;
int n = strlen(testCaseFile);
for (int i = 0; i < n;)
{
if (testCaseFile[i] == '*')
{
if (i < n - 1 && testCaseFile[i + 1] == '*')
{
i += 2;
while (i < n - 1 && !(testCaseFile[i] == '*' && testCaseFile[i + 1] == '*'))
{
if (testCaseFile[i] == '\n')
{
cleanFile[j] = '\n';
j++;
}
i++;
}
i += 2;
}
else
{
cleanFile[j] = testCaseFile[i];
j++;
i++;
}
}
else
{
cleanFile[j] = testCaseFile[i];
i++;
j++;
}
}
}