Variable Declaration and Initialization.

I am not very confident in C++. And I have a problem as following. Please help me.

In the following code, I want to send my own filename as a variable to the method loadPPM(myvariable), instead of sending it from console. How should I declare and initialize "myvariable"? :)

int main(int argc, char **argv) {
image<rgb> *input = loadPPM(argv[4]);
....
}


static image<rgb> *loadPPM(const char *name) {
std::ifstream file(name, std::ios::in | std::ios::binary);
....
}

Sincerely,
Chris

closed account (Dy7SLyTq)
just dont pass it argv[4]
Well, argv[0] is the name used to call the program to run it. Is that what you want?
I think that we are missing something.
closed account (z05DSL3A)
instead of sending it from console. How should I declare and initialize "myvariable"?


1
2
3
4
5
6
7
int main(int argc, char **argv)
{
    std::string myvariable = "somepath";
    
    image<rgb> *input = loadPPM(myvariable.c_str());
    
}
??
Last edited on
Topic archived. No new replies allowed.