Advertisement
Levii_Valenok

Untitled

May 1st, 2021
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 19.67 KB | None | 0 0
  1.  
  2. #include "Header.h"
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <stdbool.h>
  7. #include <locale.h>
  8. #include <stdbool.h>
  9. #include <ctype.h>
  10.  
  11. int inputValidation(bool type)
  12. {
  13.     int number;
  14.     char c;
  15.     if (type)
  16.     {
  17.         while (scanf("%d%c", &number, &c) != 2 || c != '\n' || number < 0)
  18.         {
  19.             rewind(stdin);
  20.             printf("Try again\n");
  21.         }
  22.     }
  23.     else
  24.     {
  25.         while (scanf("%d%c", &number, &c) != 2 || c != '\n') {
  26.             rewind(stdin);
  27.             printf("Try again\n");
  28.         }
  29.     }
  30.     return number;
  31. }
  32.  
  33. int menuForChoice ()
  34. {
  35.     int choice;
  36.     bool isTrue = true;
  37.     printf("\t1 to add elements to stack\n");
  38.     printf("\t2 to output elements\n");
  39.     printf("\t3 to delete item from stack\n");
  40.     printf("\t4 to seek by option\n");
  41.     printf("\t5 to save as file\n");
  42.     printf("\t6 to load list from file\n");
  43.     printf("\t0 to exit\n");
  44.     printf("Enter ---->");
  45.     choice = inputValidation(isTrue);
  46.     return choice;
  47. }
  48.  
  49. void pushToStack(struct geometricShapes** topOfStack)
  50. {
  51.     bool isQuite = false;
  52.     do
  53.     {
  54.         struct geometricShapes *item = *topOfStack;
  55.         if (!(*topOfStack = (struct geometricShapes *) calloc(1, sizeof(struct geometricShapes)))) {
  56.             printf("Memory is not allocated\n");
  57.             return;
  58.         }
  59.         enterArrayOfStructure(*topOfStack);
  60.         (*topOfStack)->nextItem = item;
  61.         item = *topOfStack;
  62.         printf("\tDo you want to add more?\n");
  63.         printf("\t1 to add more\n");
  64.         printf("\t2 to quite\n");
  65.         switch(rightChoice())
  66.         {
  67.             case 1:
  68.             {
  69.                 break;
  70.             }
  71.             case 2:
  72.             {
  73.                 isQuite = true;
  74.                 break;
  75.             }
  76.         }
  77.  
  78.     } while (!isQuite);
  79.  
  80. }
  81.  
  82. void enterArrayOfStructure(struct geometricShapes* pointer)
  83. {
  84.     bool isType = true;
  85.     printf("\n");
  86.     printf("Enter a square: \n");
  87.     (pointer)->square = inputValidation(isType);
  88.     printf("Enter a name: \n");
  89.     rewind(stdin);
  90.     gets((pointer)->name);
  91.  
  92.     printf("\t 1  to enter a perimeter\n");
  93.     printf("\t 2  to enter a color\n");
  94.     switch(rightChoice())
  95.     {
  96.         case 1:
  97.             printf("Enter a perimeter: \n");
  98.             (pointer)->information.perimeter = inputValidationForFloat();
  99.             (pointer)->flag = true;
  100.             break;
  101.         case 2:
  102.             printf("Enter a color: \n");
  103.             rewind(stdin);
  104.             gets((pointer)->information.color);
  105.             (pointer)->flag = false;
  106.             break;
  107.     }
  108.  
  109.  
  110. }
  111.  
  112. float inputValidationForFloat()
  113. {
  114.     float number;
  115.     char c;
  116.     while (scanf("%f%c", &number, &c) != 2  || c != '\n' || number < 0)
  117.     {
  118.         rewind(stdin);
  119.         printf("Try again\n");
  120.  
  121.     }
  122.     return number;
  123. }
  124.  
  125. int rightChoice()
  126. {
  127.     int number;
  128.     char c;
  129.     while ((scanf("%d%c", &number, &c) != 2 || c != '\n' || number < 0) || number > 3)
  130.     {
  131.         rewind(stdin);
  132.         printf("Try again\n");
  133.     }
  134.     return number;
  135. }
  136.  
  137. void mainMenu()
  138. {
  139.     bool isQuite = false;
  140.     char* nameOfFile;
  141.     struct geometricShapes* topOfTheStack = NULL;
  142.     while(!isQuite)
  143.     {
  144.         switch (menuForChoice())
  145.         {
  146.             case 1:
  147.             {
  148.                 pushToStack(&topOfTheStack);
  149.                 break;
  150.             }
  151.             case 2:
  152.             {
  153.                 outputContent(topOfTheStack);
  154.                 break;
  155.             }
  156.             case 3:
  157.             {
  158.                 menuForDelete(&topOfTheStack);
  159.                 break;
  160.             }
  161.             case 4:
  162.             {
  163.                 seekByOptions(&topOfTheStack);
  164.                 break;
  165.             }
  166.             case 5:
  167.             {
  168.                 nameOfFile = menuForSave(topOfTheStack);
  169.                 break;
  170.             }
  171.             case 6:
  172.             {
  173.                 menuForLoadFromFile(&topOfTheStack);
  174.                 break;
  175.             }
  176.             case 0:
  177.             {
  178.                 isQuite = true;
  179.                 break;
  180.             }
  181.         }
  182.     }
  183. }
  184.  
  185. void outputContent(struct geometricShapes* topOfTheStack)
  186. {
  187.  
  188.     struct geometricShapes* item = topOfTheStack;
  189.     if (item == NULL)
  190.     {
  191.         return;
  192.  
  193.     }
  194.     else
  195.     {
  196.         hatter();
  197.     }
  198.     while(item)
  199.     {
  200.         outputFigure(item);
  201.         item = item ->nextItem;
  202.         printLine();
  203.     }
  204. }
  205.  
  206. void hatter()
  207. {
  208.  
  209.     char table[] = "F i g u r ' s  t a b l e";
  210.     printf("\n");
  211.     printLine();
  212.     printf("|\t\t\t%-44s|\n", table);
  213.     printLine();
  214.     printf("|\t%-10s|\t\t%-12s|\t%-20s|\n", "SQUARE", "NAME", "PERIMETER/COLOR");
  215.     printLine();
  216. }
  217.  
  218. void printLine()
  219. {
  220.     int n = 69;
  221.     for (int i = 0; i < n; i++)
  222.     {
  223.         printf("%c", '-');
  224.     }
  225.     printf("\n");
  226. }
  227.  
  228. void outputFigure(struct geometricShapes* pointer)
  229. {
  230.     if ((pointer)->flag)
  231.     {
  232.         printf("|\t%-10d|\t%-20s|\t%-20.3f|\n", (pointer)->square, (pointer)->name,
  233.                (pointer)->information.perimeter);
  234.     }
  235.     else
  236.     {
  237.         printf("|\t%-10d|\t%-20s|\t%-20s|\n", (pointer)->square, (pointer)->name,
  238.                (pointer)->information.color);
  239.     }
  240. }
  241.  
  242. void menuForDelete(struct geometricShapes** topOfStack)
  243. {
  244.     int number;
  245.     bool isType = true;
  246.     if (topOfStack == NULL)
  247.     {
  248.         printf("Stack is empty\n");
  249.         return;
  250.     }
  251.  
  252.     printf("Enter a number of element you want to delete\n");
  253.     number = inputValidation(isType);
  254.     printf("\tAre you sure you want to delete this element?\n");
  255.     printf("\t1 yes\n");
  256.     printf("\t2 no\n");
  257.     switch(rightChoice())
  258.     {
  259.         case 1:
  260.         {
  261.             deleteAnItem(topOfStack, number);
  262.             break;
  263.         }
  264.         case 2:
  265.         {
  266.             return;
  267.         }
  268.     }
  269.  
  270. }
  271.  
  272. void deleteAnItem(struct geometricShapes** topOfStack, int number)
  273. {
  274.     if (topOfStack == NULL)
  275.     {
  276.         printf("Stack is empty\n");
  277.         return;
  278.     }
  279.     struct geometricShapes* temp = *topOfStack;                 //create new pointer and put it on the top of the stack
  280.     struct geometricShapes* previousElement = NULL;            //create pointer for previous element
  281.     struct geometricShapes* deletableItem = NULL;
  282.     struct geometricShapes* nextElement = NULL;
  283.     temp = *topOfStack;
  284.     int i = 0;
  285.     if(number == 1)
  286.     {
  287.         *topOfStack = temp->nextItem;
  288.         free(temp);
  289.         temp->nextItem = NULL;
  290.         return;
  291.     }
  292.     while(i < number - 2)
  293.     {
  294.         i++;
  295.         *topOfStack = (*topOfStack)->nextItem;
  296.         if (temp == NULL) {
  297.             break;
  298.         }
  299.  
  300.     }
  301.     previousElement = *topOfStack;
  302.     *topOfStack = (*topOfStack)->nextItem;
  303.     deletableItem = *topOfStack;
  304.     *topOfStack = (*topOfStack)->nextItem;
  305.     nextElement = *topOfStack;
  306.     previousElement->nextItem = nextElement;
  307.     *topOfStack = temp;
  308.     free(deletableItem);
  309. /*        previousElement->nextItem = temp ->nextItem;            //connect lint from previous item to next item
  310.         free(temp);
  311.         temp->nextItem = NULL;*/
  312. //    previousElement= temp;
  313. //    temp = temp->nextItem;
  314.  
  315. }
  316.  
  317. void seekByOptions(struct geometricShapes** topOfStack)
  318. {
  319.     bool isQuite = false;
  320.     while(!isQuite)
  321.     {
  322.         switch (menuForSeek())
  323.         {
  324.             case 1:
  325.             {
  326.                 seekByColor(*topOfStack);
  327.                 break;
  328.             }
  329.             case 2:
  330.             {
  331.                 seekByFloats(*topOfStack); //check it
  332.                 break;
  333.             }
  334.             case 3:
  335.             {
  336.                 seekByIntegers(*topOfStack);
  337.                 break;
  338.             }
  339.             case 0:
  340.             {
  341.                 isQuite = true;
  342.                 break;
  343.             }
  344.         }
  345.     }
  346. }
  347.  
  348. int menuForSeek()
  349. {
  350.     bool isType = true;
  351.     printf("\n");
  352.     printf("\t1 to seek by color\n");
  353.     printf("\t2 to seek by perimeter\n");
  354.     printf("\t3 to seek by square\n");
  355.     printf("\t0 to quite\n");
  356.     printf("Enter ----> ");
  357.     int choice = inputValidation(isType);
  358.     return choice;
  359. }
  360.  
  361. void seekByColor(struct geometricShapes* topOfStack) {
  362.     int index = 0;
  363.     printf("Enter a string to compare\n");
  364. //    char tempString[20];
  365.     char *tempString = (char*) calloc(20, sizeof(char));
  366.     rewind(stdin);
  367.     gets(tempString);
  368.     convertToTheSameRegister(tempString);
  369.     do
  370.     {
  371.         if (topOfStack->flag)
  372.         {
  373.             continue;
  374.         }
  375.         convertToTheSameRegister(topOfStack->information.color);
  376.         if (strcmp(topOfStack->information.color, tempString) == 0)
  377.         {
  378.             index++;
  379.             if(index == 1)
  380.             {
  381.                 hatter();
  382.             }
  383. //            printLine();
  384.             outputFigure(topOfStack);
  385.             printLine();
  386.         }
  387.  
  388.         topOfStack = topOfStack->nextItem;
  389.  
  390.     }while(topOfStack);
  391.     if (index == 0)
  392.     {
  393.         printf("There is no items with this color\n");
  394.     }
  395.     return;
  396.  
  397. }
  398.  
  399. void convertToTheSameRegister(char* string)
  400. {
  401.     int i = 0;
  402.     while (string[i] != '\0')
  403.     {
  404.         if ((string[i] >= 'a') && (string[i] <= 'z'))
  405.         {
  406.             i++;
  407.             continue;
  408.         }
  409.  
  410.  
  411.         if ((string[i] >= 'A') && (string[i] <= 'Z'))
  412.         {
  413.             string[i] = tolower(string[i]);
  414.             i++;
  415.             continue;
  416.         }
  417.         i++;
  418.     }
  419. }
  420.  
  421. void seekByIntegers(struct geometricShapes* topOfStack)
  422. {
  423.     int number, index = 0;
  424.     bool isTrue = true;
  425.     printf("Enter an integer to seek by it: \n");
  426.     number = inputValidation(isTrue);
  427.  
  428.     do
  429.     {
  430.         if (topOfStack->square == number)
  431.         {
  432.             index++;
  433.             if(index == 1)
  434.             {
  435.                 hatter();
  436.             }
  437. //            printLine();
  438.             outputFigure(topOfStack);
  439.             printLine();
  440.  
  441.         }
  442.         (topOfStack) = (topOfStack)->nextItem;
  443.     } while (topOfStack);
  444.     if (index == 0)
  445.     {
  446.         printf("There is no items with this square\n");
  447.     }
  448.     return;
  449. }
  450.  
  451. void seekByFloats(struct geometricShapes* topOfStack)
  452. {
  453.     int index = 0;
  454.     printf("Enter a float to seek by it: \n");
  455.     float number = inputValidationForFloat();
  456.     if (!(topOfStack->flag))
  457.     {
  458.         (topOfStack) = (topOfStack)->nextItem;
  459.     }
  460.     do
  461.     {
  462.         if(topOfStack->information.perimeter == number)
  463.         {
  464.             index++;
  465.             if(index == 1)
  466.             {
  467.                 hatter();
  468.             }
  469. //                printLine();
  470.             outputFigure(topOfStack);
  471.             printLine();
  472.  
  473.         }
  474.         (topOfStack) = (topOfStack)->nextItem;
  475.     }while(topOfStack);
  476.     if (index == 0)
  477.     {
  478.         printf("There is no items with this square\n");
  479.     }
  480.     return;
  481. }
  482.  
  483. int menuForLoadAsFileChoice()
  484. {
  485.     bool isType = true;
  486.     int choice;
  487.     printf("\n");
  488.     printf("\t1 to load as text file\n");
  489.     printf("\t2 to load as binary file\n");
  490.     printf("\t0 to quite\n");
  491.     choice = inputValidation(isType);
  492.     return choice;
  493. }
  494.  
  495. int menuForLoadFromFileChoice()
  496. {
  497.     bool isType = true;
  498.     int choice;
  499.     printf("\n");
  500.     printf("\t 1 to load from text file\n");
  501.     printf("\t 2 to load from binary file\n");
  502.     printf("\t0 to quite\n");
  503.     choice = inputValidation(isType);
  504.     return choice;
  505. }
  506.  
  507. char* menuForSave(struct geometricShapes* topOfStack)
  508. {
  509.     char* nameOfTheFile;
  510.     switch(menuForLoadAsFileChoice())
  511.     {
  512.         case 1:
  513.         {
  514.             saveAsTextFile(topOfStack);
  515.             break;
  516.         }
  517.         case 2:
  518.         {
  519.             saveAsBinaryFile(topOfStack);
  520.             break;
  521.         }
  522.         case 0:
  523.         {
  524.             break;
  525.         }
  526.     }
  527. }
  528.  
  529. char* enterFileName(enum fileType type, char* fileName)
  530. {
  531. //    char* fileName[20];
  532.     char letter;
  533.     int i = 0;
  534.     printf("Enter a name of the file\n");
  535.     rewind(stdin);
  536.     while (fileName[i] != '\n')
  537.     {
  538.         scanf("%c", &fileName[i]);
  539.         if (fileName[i] == '.' || fileName[i] == '*' || fileName[i] == '/' || (fileName[i] == ':')
  540.             || fileName[i] == '[' || fileName[i] == ']' || fileName[i] == '+' || fileName[i] == '-'
  541.             || fileName[i] == ';' || fileName[i] == ',')
  542.         {
  543.             printf("Incorrect name of the file. Try again\n");
  544.             fileName[0] = '\0';
  545.             rewind(stdin);
  546.             i = 0;
  547.             continue;
  548.         }
  549.         if (fileName[i] == '\n')
  550.         {
  551.             break;
  552.         }
  553.         i++;
  554.     }
  555.  
  556.     switch(type)
  557.     {
  558.         case 1:
  559.         {
  560.             fileName[strlen(fileName)-1] = '\0';
  561.             char expansion[5] = ".bin";
  562.             strcat(fileName, expansion);
  563.             return fileName;
  564.             break;
  565.         }
  566.         case 2:
  567.         {
  568.             fileName[strlen(fileName)-1] = '\0';
  569.             char expansion[5] = ".txt";
  570.             strcat(fileName, expansion);
  571.             return fileName;
  572.             break;
  573.         }
  574.     }
  575.  
  576.  
  577. }
  578.  
  579. void saveAsTextFile(struct geometricShapes* topOfStack)
  580. {
  581. //    int n = 69;
  582. //    char* nameOfTheFile = enterFileName(TEXTFILE, nameOfTheFile);
  583.     char nameOfTheFile [] = "TestFileForTextFile.txt";
  584.     FILE* textFilePointer = fopen(nameOfTheFile, "w+");
  585.     if (textFilePointer == NULL)
  586.     {
  587.         perror("An error occurred while opening the file\n");
  588.         exit(0);
  589.     }
  590.     rewind(textFilePointer);
  591.     while (topOfStack)
  592.     {
  593.         if(topOfStack->flag)
  594.         {
  595.             fprintf(textFilePointer, "%d\n%s\n%fl\n", topOfStack->square, topOfStack->name, topOfStack->information.perimeter);
  596.         }
  597.         else
  598.         {
  599.             fprintf(textFilePointer, "%d\n%s\n%s\n", topOfStack->square, topOfStack->name, topOfStack->information.color);
  600.         }
  601.         topOfStack = topOfStack->nextItem;
  602.     }
  603.     fclose(textFilePointer);
  604. }
  605.  
  606. void outputFigureToFle(struct geometricShapes* pointer, FILE* textFilePointer)
  607. {
  608.     if ((pointer)->flag)
  609.     {
  610.         fprintf(textFilePointer, "|\t%-10d|\t%-20s|\t%-20.3f|\n", (pointer)->square, (pointer)->name,
  611.                (pointer)->information.perimeter);
  612.     }
  613.     else
  614.     {
  615.         fprintf(textFilePointer, "|\t%-10d|\t%-20s|\t%-20s|\n", (pointer)->square, (pointer)->name,
  616.                (pointer)->information.color);
  617.     }
  618. }
  619.  
  620. void menuForLoadFromFile(struct geometricShapes** topOfStack)
  621. {
  622.  
  623.     switch(menuForLoadAsFileChoice())
  624.     {
  625.         case 1:
  626.         {
  627.             loadFromTextFile(&topOfStack);
  628.             break;
  629.         }
  630.         case 2:
  631.         {
  632.             loadFromBinaryFile(&topOfStack);
  633.             break;
  634.         }
  635.     }
  636. }
  637.  
  638.  
  639. void loadFromTextFile(struct geometricShapes** topOfStack)
  640. {
  641.     bool isType = false;
  642.     char nameOfTheFile[] = "TestFileForTextFile.txt";
  643.     int tempNumber;
  644.     struct geometricShapes *copyOfStack = *topOfStack;
  645.     struct geometricShapes *tempStack = *topOfStack;
  646.     FILE *filePointer = fopen(nameOfTheFile, "r");
  647.     rewind(filePointer);
  648.     while (!feof(filePointer))
  649.     {
  650.  
  651.             if (!(*topOfStack = (struct geometricShapes *) calloc(1, sizeof(struct geometricShapes)))) {
  652.                 printf("Memory is not allocated\n");
  653.                 return;
  654.             }
  655.             if (feof(filePointer))
  656.             {
  657.                 break;
  658.             }
  659. //            fscanf(filePointer, "%c", &letter);
  660.              fscanf(filePointer, "%d", &tempNumber);
  661.             fscanf(filePointer, "%d", &(*topOfStack)->square);
  662.             fseek(filePointer, 2, SEEK_CUR);
  663.             fgets((*topOfStack)->name, 20, filePointer);
  664.             (*topOfStack)->name[strlen((*topOfStack)->name) - 1] = '\0';
  665.             if ((*topOfStack)->flag) {
  666.                 fscanf(filePointer, "%f", &(*topOfStack)->information.perimeter);
  667.             } else {
  668.                 fgets((*topOfStack)->information.color, 20, filePointer);
  669.                 (*topOfStack)->information.color[strlen((*topOfStack)->information.color) - 1] = '\0';
  670.             }
  671.             outputContent(*topOfStack);
  672.             (*topOfStack)->nextItem = copyOfStack;
  673.             copyOfStack = *topOfStack;
  674.         }
  675.         if (*topOfStack == NULL) {
  676.             printf("The contents of the file were not pushed onto the stack\n");
  677.         } else {
  678.             printf("The contents of the file were pushed onto the stack successful\n");
  679.         }
  680.         fclose(filePointer);
  681.         printf("Content is :\n");
  682.         outputContent(*topOfStack);
  683.     }
  684.  
  685.  
  686. //struct geometricShapes* push(struct geometricShapes** topOfStack, struct geometricShapes* item)
  687. //{
  688. //    struct geometricShapes *pointer = (struct geometricShapes *)calloc(1, sizeof(struct geometricShapes));
  689. //    pointer = item;
  690. //    pointer->nextItem = *topOfStack;
  691. //    *topOfStack = pointer;
  692. //
  693. //    return *topOfStack;
  694. //}
  695. //
  696. //struct geometricShapes* pop(struct geometricShapes** topOfStack)
  697. //{
  698. //    struct geometricShapes* pointer = *topOfStack;
  699. //    *topOfStack = pointer->nextItem;
  700. //    int value = node->value;
  701. //    free(node);
  702. //
  703. //    return value;
  704. //}
  705.  
  706. void saveAsBinaryFile(struct geometricShapes* topOfStack)
  707. {
  708. //    char* nameOfTheFile = enterFileName(BINARYFILE, nameOfTheFile);
  709.     char nameOfTheFile [] = "TestFileForBinaryFile.bin";
  710.     FILE* binaryFile = fopen(nameOfTheFile, "wb");
  711.     while (topOfStack)
  712.     {
  713.         if (topOfStack->flag)
  714.         {
  715.             fwrite(topOfStack->name, strlen(topOfStack->name), 1, binaryFile);
  716.             fwrite(&(topOfStack->square), sizeof(int), 1, binaryFile);
  717.             fwrite(&(topOfStack->information.perimeter), sizeof(float), 1, binaryFile);
  718.         }
  719.         else
  720.         {
  721.             fwrite(topOfStack->name, strlen(topOfStack->name), 1, binaryFile);
  722.             fwrite(&(topOfStack->square), sizeof(int), 1, binaryFile);
  723.             fwrite((topOfStack->information.color), strlen(topOfStack->information.color), 1, binaryFile);
  724.         }
  725.         topOfStack = topOfStack->nextItem;
  726.     }
  727.     fclose(binaryFile);
  728. }
  729. void loadFromBinaryFile(struct geometricShapes** topOfStack)
  730. {
  731.     char nameOfTheFile [] = "TestFileForBinaryFile.bin";
  732.     FILE* binaryFile = fopen(nameOfTheFile, "rb");
  733.     struct geometricShapes* copyOfStack = *topOfStack;
  734.     struct geometricShapes* tempStack = *topOfStack;
  735.     rewind(binaryFile);
  736.     while (!feof(binaryFile))
  737.     {
  738.         if (!(copyOfStack = (struct geometricShapes*)calloc(1, sizeof(struct geometricShapes))))
  739.         {
  740.             printf("Memory was not allocated\n");
  741.             return;
  742.         }
  743.         if (copyOfStack ->flag)
  744.         {
  745.             fgets((copyOfStack)->name, 20 , binaryFile);
  746.             deleteSymbols((copyOfStack)->name);
  747. //            fscanf(binaryFile, "%s", &(copyOfStack)->name);
  748.             fscanf(binaryFile, "%d", &(copyOfStack)->square);
  749.             fscanf(binaryFile, "%fl", &(copyOfStack)->information.perimeter);
  750.         }
  751.         else
  752.         {
  753.             fgets((copyOfStack)->name, 20, binaryFile);
  754.             deleteSymbols((copyOfStack)->name);
  755. //            fscanf(binaryFile, "%s", &(copyOfStack)->name);
  756.             fscanf(binaryFile, "%d", &(copyOfStack)->square);
  757. //            fscanf(binaryFile, "%s", &(copyOfStack)->information.color);
  758.             fgets((copyOfStack)->information.color, 20, binaryFile);
  759.             deleteSymbols((copyOfStack)->information.color);
  760.         }
  761.         (copyOfStack)->nextItem = *topOfStack;
  762.         *topOfStack = copyOfStack;
  763.     }
  764.     fclose(binaryFile);
  765. }
  766. void deleteSymbols(char* string)
  767. {
  768.     int i = 0;
  769.     while (string[i] != '\0')
  770.     {
  771.         if (string[i] == '\n')
  772.         {
  773.             string[i] = '\0';
  774.         }
  775.         i++;
  776.     }
  777. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement