-
Notifications
You must be signed in to change notification settings - Fork 0
/
random.c
54 lines (52 loc) · 847 Bytes
/
random.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"headers.h"
void tail(FILE* in, int n){
int count = 0;
long int pos;
char s[100];
if(in == NULL) {
perror("fopen");
exit(EXIT_FAILURE);
}
fseek(in, 0, SEEK_END);
pos = ftell(in);
while(pos){
fseek(in, --pos, SEEK_SET);
if(fgetc(in) == '\n') {
if(count++ == 10)
break;
}
}
while(fgets(s, sizeof(s), in) != NULL) {
printf("%s\n", s);
}
fclose(in);
}
void tilda(char *t, char *f){
int i, j, k, flag;
for(j = 0; j < (int)strlen(ft); j++){
if(t[j] == ft[j])
flag = 1;
else{
flag = 0;
break;
}
}
if(flag == 1){
k = 0;
f[k] = '~';
i = strlen(ft);
while(i < strlen(t)){
f[++k] = t[i];
i++;
}
f[++k]='\0';
}
else{
i = 0;
while(t[i] != '\0'){
f[i] = t[i];
i++;
}
f[i] = '\0';
}
}