SHARE
TWEET

Untitled

a guest Oct 21st, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     char * file_name;
  7.     const n = 128;
  8.     file_name = (char *) malloc(n*sizeof(char));
  9.     int file_name_length = 0;
  10.     printf("Please, enter the file name:\n");
  11.     scanf("%s", file_name);
  12.     //printf("%s\n", file_name);
  13.    // freopen(file_name,"rb", stdin);
  14.  
  15.     char c;
  16.  
  17.     printf("What do you want to do with this fail? To separate it into bits(s) or into pieces of equal length(n)?\n");
  18.     char x;
  19.     //fclose(stdin);
  20.     scanf("%c", &x);
  21.     printf("%c", x);
  22.     if (x == 's')
  23.     {
  24.         int length_s;
  25.         printf("Enter the number of bits:\n");
  26.         scanf("%d", &length_s);
  27.         printf("Enter the name of file where you want to save you file:");
  28.         char * name;
  29.         name = (char*) malloc(n * sizeof(char));
  30.         scanf("%s", name);
  31.         int number_of_files = file_name_length / length_s;
  32.  
  33.         const char * str = name;
  34.         for (; *str; str++)
  35.         {}
  36.         int length_name = str - name;
  37.         printf("%d", length_name);
  38.  
  39.     /*  freopen(file_name,"rb", stdin);
  40.         while (scanf("%c", &c) != EOF)
  41.         {
  42.             file_name_length++;
  43.         }
  44.  
  45.  
  46.         for (int i = 0; i < number_of_files; i++)
  47.         {
  48.             name[length_name - 1] = i + '0';
  49.             freopen(name,"rb", stdin);
  50.             for(int j = 0; j < length_s; j++)
  51.             {
  52.                 scanf("%c", &c);
  53.                 printf("%c", c);
  54.             }
  55.  
  56.         }*/
  57.  
  58.  
  59.     }
  60.  
  61.  
  62.  
  63. }
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