Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <stdio.h>
- #include "caesar.h"
- //функция создает массив ключей
- int key_temp(FILE *text, char *arr, const char *arr1, int *arr3) {
- char *token;
- int n = 0;
- int i = 0;
- int j = 0;
- while ((fgets(arr, 1024, text)) != NULL) {
- token = strtok(arr, arr1);
- i = 0;
- while (token != NULL) {
- if (*(arr + i) != NULL) {
- n += (int) *(arr + i);
- i++;
- } else {
- n/=128;
- *(arr3 + j) = n;
- j++;
- n = 0;
- i++;
- token = strtok(NULL, arr1);
- }
- }
- }
- return *(arr3 + i);
- }
- //функция кодирует инфу
- void coding(FILE *source,FILE *code,const int *arr) {
- char c;
- c = getc(source);
- int i = 0;
- while (!feof(source)) {
- c += *(arr + i);
- if (c > 127)
- c -= 127;
- fprintf(code, "%c", c);
- i++;
- if (i > 170) {
- i = 0;
- }
- c = getc(source);
- }
- }
- //функция декодирует инфу
- void decoding(FILE *code,FILE *decode1,const int *arr) {
- char c;
- c = getc(code);
- int i = 0;
- while (!feof(code)) {
- c -= *(arr + i);
- if (c < 0)
- c += 127;
- fprintf(decode1, "%c", c);
- i++;
- if (i > 170) {
- i = 0;
- }
- c = getc(code);
- }
- }
- //вывод текста
- void print_text(FILE *text,int len,char *arr){
- while((fgets(arr,len,text))!=0){
- printf("%s",arr);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment