Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define N 1024
- void alloc(char** s);
- void matrixFree(char** s, int count);
- void textToMas(char** s, int& count, FILE* f1);
- void textInput(char** s, int count, FILE* f2);
- int main()
- {
- char** s = new char* [N];
- alloc(s);
- FILE* f1 = fopen("original.txt", "r");
- FILE* f2 = fopen("edited.txt", "w");
- int count = 0;
- textToMas(s, count, f1);
- textInput(s, count, f2);
- matrixFree(s, count);
- fclose(f1);
- fclose(f2);
- return 0;
- }
- void alloc(char** s)
- {
- for (int i = 0; i < N; i++)
- s[i] = new char[N];
- }
- void matrixFree(char** s, int count)
- {
- for (int i = 0; i < N; i++)
- delete[] s[i];
- delete[] s;
- }
- void textInput(char** s, int count, FILE* f2)
- {
- int j = 1;
- for (int i = 0; i < count; i++)
- {
- if (s[i][0] == '\n') continue;
- else
- {
- fprintf(f2, "%d.", j);
- j++;
- fputs(s[i], f2);
- }
- }
- }
- void textToMas(char** s, int& count, FILE* f1)
- {
- for (int i = 0; !feof(f1); i++)
- {
- if (i == N)
- {
- count--;
- break;
- }
- fgets(s[i], N, f1);
- count++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement