daily pastebin goal
18%
SHARE
TWEET

Untitled

a guest May 16th, 2018 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h> //random
  4. #include <string.h> // char commands
  5. #include <windows.h> //for colors [works only on windows]
  6.  
  7. //codes a text that the user inputs with the delay requested then decodes it in a file.
  8.  
  9. int main ()
  10. {
  11.    char str1[500];
  12.    int delay = 0;
  13.    int codedelay = 0;
  14.    int chainlength = 0;
  15.    int i = 0;
  16.    FILE* fichier = NULL;
  17.  
  18.    fichier = fopen("decoder.txt", "w+");
  19.  
  20.    if(fichier != NULL)
  21.    {
  22.     printf("Write a text\n\n");
  23.     fprintf(fichier, "Your text: \n\n");
  24.     fgets(str1, 1000, stdin);
  25.     fprintf(fichier, "%s", str1);
  26.     printf("How much delay should there be to your text(you may use negative delay too)?\n\n");
  27.     scanf("%d", &delay);
  28.     chainlength = strlen(str1);
  29.             for(i = 0; i < chainlength; i++)
  30.             {
  31.                 codedelay = str1[i]+delay;
  32.                 str1[i] = codedelay;
  33.             }
  34.         fprintf(fichier, "\n\nYour text coded:\n\n%s", str1);
  35.             for(i = 0; i < chainlength; i++)
  36.             {
  37.                 codedelay = str1[i]-delay;
  38.                 str1[i] = codedelay;
  39.             }
  40.         fprintf(fichier, "\n\nYour text decoded : \n\n%s", str1);
  41.    }
  42.    else
  43.    {
  44.     printf("File could not be open");
  45.    }
  46.    fclose(fichier);
  47.  
  48.    return(0);
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top