diff options
author | Akshay <[email protected]> | 2021-04-16 05:32:24 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2021-04-16 05:32:24 +0100 |
commit | 5b54c1d51afad68d497a14d8c5e3a9fc852d5f20 (patch) | |
tree | 7049e5c50ed87b312fb9f11460c21fb3148b9e76 /4 | |
parent | a83f7edacd5d4a72c29d836ec2338ffa23bec38a (diff) |
add prog 4
Diffstat (limited to '4')
-rw-r--r-- | 4/input | 5 | ||||
-rw-r--r-- | 4/main.l | 33 |
2 files changed, 38 insertions, 0 deletions
@@ -0,0 +1,5 @@ | |||
1 | int main() { | ||
2 | int n; | ||
3 | printf("hello world"); | ||
4 | scanf("%d", &n); | ||
5 | } | ||
diff --git a/4/main.l b/4/main.l new file mode 100644 index 0000000..f768382 --- /dev/null +++ b/4/main.l | |||
@@ -0,0 +1,33 @@ | |||
1 | %{ | ||
2 | |||
3 | int scans = 0; | ||
4 | int prints = 0; | ||
5 | %} | ||
6 | |||
7 | %% | ||
8 | scanf { | ||
9 | scans++; | ||
10 | fprintf(yyout, "readf"); | ||
11 | }; | ||
12 | printf { | ||
13 | prints++; | ||
14 | fprintf(yyout, "writef"); | ||
15 | } | ||
16 | ; fprintf(yyout, "%s", yytext); | ||
17 | \n fprintf(yyout, "\n"); | ||
18 | %% | ||
19 | |||
20 | int main(void) { | ||
21 | yyin=fopen("4/input", "r+"); | ||
22 | yyout=fopen("4/output", "w"); | ||
23 | yylex(); | ||
24 | printf("%d printf occurrences\n", prints); | ||
25 | printf("%d scanf occurrences\n", scans); | ||
26 | } | ||
27 | |||
28 | int yywrap() | ||
29 | { | ||
30 | exit(0); | ||
31 | return(1); | ||
32 | } | ||
33 | |||