-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathass2.c
69 lines (62 loc) · 1.38 KB
/
ass2.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
66
67
68
69
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char *file = malloc(80);
for (int i = 0; i < 9; i++)
{
if ((argv[2][i] == 't') || (argv[2][i] == 'x') || (argv[2][i] == 'e') || (argv[2][i] == '.'))
{
file[i] = argv[2][i];
}
}
printf("%s\n", file);
FILE *input = fopen(file, "r"); // read
if (input) // file opened OK
{
char titel[100];
char WahlA[100];
char WahlB[100];
char Anzeigetext[100];
int zeilebuchstaben = 0;
fseek(input , 0 , SEEK_SET);
fgets(titel,100,input);
printf ("%s", titel);
for (int y = 0; y <= 100; y++)
{
if (titel[y] == '\n')
{
zeilebuchstaben = y + 1;
break;
}
}
fseek(input , zeilebuchstaben , SEEK_SET);
fgets(WahlA,100,input);
printf ("%s", WahlA);
for (int y = 0; y <= 100; y++)
{
if (WahlA[y] == '\n')
{
zeilebuchstaben = zeilebuchstaben + y + 1;
break;
}
}
fseek(input , zeilebuchstaben , SEEK_SET);
fgets(WahlB,100,input);
printf ("%s", WahlB);
for (int y = 0; y <= 100; y++)
{
if (WahlB[y] == '\n')
{
zeilebuchstaben = zeilebuchstaben + y + 1;
break;
}
}
fseek(input , zeilebuchstaben , SEEK_SET);
fgets(Anzeigetext,100,input);
printf ("%s", Anzeigetext);
}
fclose(input);
free(file);
return 0;
}