#include <stdlib.h>
List extr(char *sA[], int n, int (*f)(char *)) {
List L = NULL;
for (int i = 0 ; i < n ; i++)
if (f(sA[i])) {
Elem *e = malloc(sizeof(Elem));
e->str = sA[i];
e->next = L;
L = e;
}
return L;
}
#include <stdio.h>
#include <string.h>
int txt2bin(char *tF, char *bF) {
FILE *t = fopen(tF, "r");
FILE *b = fopen(bF, "wb");
int n = 0;
char info[100];
Rec r;
while (fscanf(t, "%ld %s", &(r.cod), info) == 2) {
if (strlen(info) < 10) {
strcpy(r.info, info);
fwrite(&r, sizeof(Rec), 1, b);
n++;
}
}
fclose(t);
fclose(b);
return n;
}
#include <stdlib.h>
#include <string.h>
SList repcpy(SList L, int k, SList R) {
SList *p = &L;
while (*p != NULL && k > 1) {
p = &((*p)->next);
k--;
}
if (*p != NULL) {
SElem *next = (*p)->next;
free((*p)->str);
free(*p);
while (R != NULL) {
SElem *e = malloc(sizeof(SElem));
e->str = malloc(strlen(R->str) + 1);
strcpy(e->str, R->str);
*p = e;
p = &((*p)->next);
R = R->next;
}
*p = next;
}
return L;
}