cout << "I want to use this array to print out all the numbers from my text file but i cant
argv is an array of c-strings that contain the command line arguments given to your program. To print out all the numbers from your text file, you open your text file and read/print all of the numbers therein. argv doesn't play into it except for providing the file name specified via the command line.
#include <iostream>
#include <fstream>
int main(int argc, char*argv [])
{
if (argc < 2) {
std::cerr << "Please specify the file name when invoking this program.\n";
return 0;
}
std::ifstream in(argv[1]);
if (!in) {
std::cerr << "Unable to open input file \"" << argv[1] << "\"\n";
return 0;
}
int value;
while (in >> value)
std::cout << value << '\n';
}