Open and close a file in c++

Hello guys,
I have 2 tiny question about open and close a file in c++, cause the program dont iexplore dont close and put a text in code format this forum. For example:

<code>
#include <iostream>
#include <Windows.h>

using namespace std;

int main()
{
system("start iexplore.exe http://www.google.com");
system("exit iexplore.exe");
}

</code>

The program iexplore.exe dont close, Why?
system will not return until the command is finished. That means system("exit iexplore.exe"); will not run until after you have closed Internet Explorer.
Last edited on
you can hack around this with
system("start iexplore.exe")

I think. I know start lets the program move on, or it should, but unclear if you can kill it.
Last edited on
Ah, so that's what start does. I don't think exit will work in this situation. You might have better luck with taskkill.

 
system("taskkill /im iexplore.exe");

Now, I have to admit that I don't fully understand what opening and closing Internet Explorer is supposed to accomplish.

By the way, <code> and </code> should be [code] and [/code] if you want to display the code with syntax highlighting and formatting intact.
Last edited on
Thanks a lot man
Topic archived. No new replies allowed.