-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
53 lines (47 loc) · 1.26 KB
/
main.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*-----------------------------------------------------
---------bu kısımda kullanıcıdan hedef yolu + ---------
---------- dosya tipini + uzantisini almayi -----------
------------ planliyoruz.------------------------------
int main(){
const char r;
int o,a,d;
printf("hangi yoldaki dosyalari duzenlemek istersiniz?\n");
scanf("%c", &r);
printf("dosyanın uzantisi nedir?\n");
scanf("%d", &o);
printf("dosyanin adi nedir?\n");
scanf("%d", &a);
{
char str[100];
char* nstr;
char s;
int i=0;
FILE *file;
file = fopen(r , "r");
if (file)
{
// dosyayı bastan sona array ile tara ve arrayda topla
while((s=fgetc(file)) != EOF)
{
str[i]=s;
i++;
}
//tanımadigimiz array i satir baslari ile ayiriyoruz
nstr = strtok(str, "\n"); // char* = strtok(char[]," ")-> (fonksiyon tanımı)
//nstr = IP:192.168.10.10(örnegin dosyanın icinde olan ip)
//array ile tanimladigimiz stringi printf ile yazdiriyoruz sonra kiriyoruz.
while(nstr != NULL)
{
printf("%s\n", str);
nstr = strtok(str, "\n");
break;
}
// dosyasyı kapat
fclose(file);
}
return 0;
}
}