Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <string>
- #include <sstream>
- #include "sub.h"
- int main()
- {
- std::ifstream file;
- file.open(...);
- if (!file) {
- std::cerr << "Error opening file." << std::endl;
- return EXIT_FAILURE;
- }
- int n;
- std::string firstLine;
- getline(file, firstLine);
- std::stringstream(firstLine) >> n;
- int a,b,c;
- std::vector<int> A1,B1,C1;
- while (file >> a >> b >> c) {
- A1.push_back(a);
- B1.push_back(b);
- C1.push_back(c);
- }
- file.close();
- std::ofstream output;
- output.open(...);
- output << n << "\n";
- size_t size = A1.size();
- for (size_t i=0; i<size; ++i) {
- output << A1[i] << " " << B1[i] << " " << C1[i] << std::endl;
- }
- //call sub method with pointer to beginning of vectors
- //I have no control over sub method, its signature is (int, int*, int*, int*)
- int n1 = sub(n, &A1[0], &B1[0], &C1[0]);
- //output result and close file
- output << n1;
- output.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment