Could someone please tell me how exactly I'm supposed to "create an array of ints? I will be given a .txt file that I will have to read with an unknown amount of data, so I don't know exactly what size the array will be.
#include <vector>
#include <ifstream>
int main()
{
std::vector<int> array ;
std::ifstream file ( "myfile" ) ;
int n ;
while( file >> n ) array.push_back(n) ;
// array.size() ints have been read into array
// use array
}
ok, I sort of see what you're doing now. Now on your comment for array.size(), your basically finding the size of the array right. And nothing goes between the parentheses? And then I don't know what you mean for your comment //use array.
> array.size(), your basically finding the size of the array right.
Yes.
> And then I don't know what you mean for your comment //use array.
You wouldn't have read the numbers in the file into array unless you wanted to do something with those numbers. So use the array - do whatever it is that you are supposed to do with the numbers.