-
Notifications
You must be signed in to change notification settings - Fork 0
/
Untitled1.c
65 lines (44 loc) · 1.24 KB
/
Untitled1.c
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int i;
FILE *fp = NULL;
fp = fopen("Wall_01_Allplan.ifc", "r");
FILE *out = fopen("out.txt", "a");
if (fp == NULL)
{
printf(" file not not found");
return 0;
}
char buffer[10000][40];
char str[10000][40];
char pattern[] = "IFCOPENINGELEMENT";
int k = 0;
int l = 0;
while (fgets(buffer[k], sizeof(buffer), fp) != NULL)
{
if(buffer[k][strlen(buffer[k]-1)]!=';')
{
strcat(buffer[k-1],buffer[k]);
if (strstr(buffer[k], pattern))
{
int n = 9;
int i = k - 4;
while (n--)
{
fgets(str[i], sizeof(str), fp);
fputs(str[i], stdout);
fprintf(out, "%s\n", str[i]);
i++;
}
}
k++;
if (k > 9000)
k = 0;
}
}
return 0;
}