How do you count the purple from the binary file using read()?
-
void read(int* arr) { ifstream file_if; file_if.open("arr.txt", ios::binary); if (!file_if.is_open()) cout << "error opening file for reading" << endl; else file_if.read((char*)&arr, size); file_if.close(); }
size - volume measurement;
file_if.read(char*) representarr, size); - reading from the file immediately into the whole range, before that, the record was in the file "file_of.write(char*) gauger, size);
-
file_if.read((char*)arr, size * sizeof(int));
Reading a whole body;file_if.read((char*)&arr, sizeof(int));
- reading one variable on which the index standsseekg()
(on default at the beginning of the file);for (int index = 0; index < size; ++index) {file_if.read((char*)arr[index], sizeof(int));}
- reading one element in your mass under the number.index
;
Works this way: we count the element on the file and keep it in the room.index
after which the index is moved to sizeof(int);