If your doing command line you can pass it as an arg... I would think at least.
Code:
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char* argv[])
{
ifstream infile;
char *filepath;
char var1[80];
filepath = new char[strlen(argv[1])+1];
strcpy(filepath,argv[1]);
infile.open(filepath);
infile>>var1; //loop this to read next chunk of data
return 0;
}
I don't know the PGM layout, but you can use this general code to read from a file. Whitespace will break the read by the way so we don't always grab 80 chars of data just seperate chunks this might help some.