Hey everyone, I have a quick (and hopefully simple question). I'm writing a simple program that will ask the user for two different inputs(IP address and message), save those as strings, then run a command in command prompt adding those strings on the end as arguments. I'm using it to change the message displayed on HP printer screens by using a little program called HPhack. In command prompt, it would look like this:

HPHack.exe 192.168.10.1 "Message!!"

I'm using system("command") right now, but I don't know how to pass those arguments along with it.


Thanks!

cout<<"Enter IP address of target printer:"<<endl;
    getline (cin, ip);
    
    cout<<"Enter message in quotes:"<<endl;
    getline (cin, message);
    
    system("hphack.exe "ip" "message);

Hmmm.... I don't know if I should respond to this. Something smells fishy here.

Don't worry, I'm not using it maliciously. Me and my boss want to use it to mess with someone a little. I can do it without this code, but I'm also learning C++ and really do want to know how to do this, regardless of this specific instance.

I thought about being more general because I knew someone would respond like this, but I thought I'd be open to begin with!

OK, if you want, you could read how to do it here... Don't misuse it though.

Thank you! I really won't misuse it. I know this will come in handy sometime in the future though.

Thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.