Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- using namespace std;
- FILE *fl;
- FILE *fl2;
- int main()
- {
- if ( (fl = fopen("chisla", "wb+")) == NULL) // creating
- {
- cout << "File is NOT created";
- }
- else
- {
- cout << "File is created";
- }
- cout << endl;
- int n;
- cout << "Vvedite razmer massiva" << endl;
- cin >> n;
- int * mass = new int [n];
- for (int i = 0; i < n; i++)
- {
- cout << "[" << i << "] = ";
- cin >> mass[i];
- }
- cout << endl;
- fwrite(mass,sizeof(mass),1,fl);
- fclose(fl);
- if((fl = fopen("chisla", "rb+")) == NULL)
- {
- cout << "File is not opened!";
- }
- fread(mass,sizeof(mass), 1, fl);
- fclose(fl);
- if ((fl = fopen("chisla" , "rb+")) == NULL)
- {
- cout << "File is not opened!";
- }
- int x, nech = 0, pl = 0;
- while (fread(&x, sizeof(int), 1, fl) == 1)
- {
- if ((x - 1) % 2 != 0 && x + 1 > 0)
- nech++;
- }
- cout << "nech = " << nech;
- if((fl2 = fopen("file2", "wt+")) == NULL)
- {
- cout << "Oshibka pri sozdanii txt!" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement