Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <string>
- int main() {
- std::vector<int> Array = { 1, 2, 4, 8, 1, 2, 3, 4, 5 };
- // Open the file and read values
- std::ifstream inputFile("1_file.txt");
- if (!inputFile) {
- std::cerr << "Error opening file!" << std::endl;
- return 1;
- }
- int value;
- while (inputFile >> value) {
- Array.push_back(value);
- }
- inputFile.close();
- std::cout << "Updated Array: ";
- for (int num : Array) {
- std::cout << num << " ";
- }
- std::cout << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement