Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- void arrayOutput(int sizeArray, int* array, ifstream& file) {
- for (int i = 0; i < sizeArray; i++) {
- file >> array[i];
- cout << array[i] << endl;
- }
- }
- int main(int argc, const char * argv[]) {
- ifstream file("text.txt");
- int array1[2], array2[4];
- if (!file) {
- cout << "error" << endl;
- return 0;
- }
- cout << "first array" << endl;
- arrayOutput(2, array1, file);
- cout << "second array" << endl;
- arrayOutput(4, array2, file);
- file.close();
- return 0;
- }
- // СОДЕРЖИМОЕ ФАЙЛА "text.txt":
- /*
- 4
- 3
- 7
- 9
- 5
- 6
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement