-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheight.c
55 lines (40 loc) · 1.29 KB
/
eight.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//'Deneme.txt' dosyasi, kod dosyasiyla ayni dosyada olmalidir yoks ==> 'Kosya yoktur!'
//test file must be in the same directry
int main() {
int max = 50;
int x , y;
char fix[max];
int num = 0;
//'filename', "Deneme.txt" dosyasinin adini saklar ve ardindan bir dosya isaretcisi bildirir
char filename[] = "Deneme.txt";
//"r+" modu, dosya uzerinde hem okuma hem de yazma islemlerine izin verir
FILE* file = fopen(filename, "r+");
//dosyanin bos olup olmadigini kontrol edin
if (file == NULL) {
printf("Dosya yoktur!");
return 1;
}
char str[max];
fscanf(file, "%s", str);
//belirli sifre kullanarak metni cozer.
int len = strlen(str);
for ( x = 0; x < len; x += 2) {
char ch = str[x];
int count = str[x + 1] - '0';
for ( y = 0; y < count; y++) {
fix[num++] = ch;
}
}
fix[num] = '\0';
fseek(file, 0, SEEK_SET);
/* SEEK_SET Bir dosya icinde arama yapmak icin referans noktasini belirtmek uzere
fseek islevinde ucuncu bagimsiz degisken olarak kullanilir. , SEEK_SET = 0; */
fprintf(file, "%s : %s", str, fix);
fclose(file);
//Islem bittiyse ekrana 'done' yazin
printf("done :) ");
return 0;
}