I have this file:
4
10 3 4 6
The first line declares how many numbers the second line has.I want to put the numbers of the second line in an array.So far i have been using this loop to automatically declare how many numbers the second line has and how many times to do the loop:
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
int main(){
ifstream infile;
infile.open("input.in");
string kids;
int x;
int i;
getline(infile,kids);
cout << "The Number Of Kids Is " << kids << endl;
istringstream buffer(kids);
int kidss;
buffer >> kidss;
for(i=0;i<kidss;i++){
infile >> x;
cout << x << " ";
}
infile.close();
return 0;
}
Now i want to do the same thing but instead of inputing the numbers in x i want to put them in an array and then display them as above.Thanks In Advance!
std::vectorand thepush_back()function.