Hi,
I was hoping someone could help me out with this problem, C++ is a bit new to me.
Basically, I want to have a program which takes in a filename in the main function and passes it to a function within a class. Here's my attempt so far, which as you can guess isn't working.
class Parse
{
public:
Parse(); // default constructor
~Parse(); // deconstructor
void File(char* argv[]); //opens and reads in file
private:
};
Thanks helios, but could you elaborate a little on your reply.
I agree I should use a more descriptive name than argv, but can you explain the first part of your answer a bit more.
It's simple.
argv, as declared in main(), is a char **, a pointer to an array of pointers to arrays of chars. Each element of argv should therefore be a char *, a pointer to an array of chars.
If you want to just pass argv, remove the "[1]" from your call to Parse::File().
Keep in mind that char *var[] is the same as char **var
The reason for this is that behind the scenes, when a parameter type is param[], it is interpreted as *param in c++. Similarly, *(param[]) is equivalent to *(*param), or just **param.