"system" function problem

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

Locked
Pofis
Posts: 14
Joined: 2003-11-25 14:06
Location: Portugal
Contact:

"system" function problem

Post by Pofis » 2004-03-14 13:02

imagine something like this:

Code: Select all

	string file;

	file = "some_random_file";
	temp = "file.exe " + file + " > temp.txt";
	system(temp);
	// then read temp.txt file, and do some stuff
but i get this error:

Code: Select all

client\Util.cpp(617) : error C2664: 'system' : cannot convert parameter 1 from '_STL::string' to 'const char *'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
is any function in STLport that i can use instead of "system"? because "file" must be defined as string.

Thanks in advance.

Pofis

Qbert
Posts: 73
Joined: 2003-06-07 03:12

Post by Qbert » 2004-03-14 13:07

c_str() converts to a const char *.

Code: Select all

temp.c_str();
My Visual Studio .NET 2003 is licensed under my name, and the same for my operating system... What about you?
I surf on an OC3 without limitations, two to be exact, and I'm not joking.

Pofis
Posts: 14
Joined: 2003-11-25 14:06
Location: Portugal
Contact:

Post by Pofis » 2004-03-14 13:16

thanks alot :D

Pofis

Pofis
Posts: 14
Joined: 2003-11-25 14:06
Location: Portugal
Contact:

Post by Pofis » 2004-03-15 14:53

Now i have another problem :( , when executing the "system" function the command line opens and closes.
is there any way to run it on "background" ?

Thanks

Pofis

ivulfusbar
Posts: 506
Joined: 2003-01-03 07:33

Post by ivulfusbar » 2004-03-15 17:01

using system() calls is among the worse things you can do. It opens up your system for an extream amount of abuse. Don't. Why do you need to use system-calls?
Everyone is supposed to download from the hubs, - I don´t know why, but I never do anymore.

Pofis
Posts: 14
Joined: 2003-11-25 14:06
Location: Portugal
Contact:

Post by Pofis » 2004-03-16 07:42

I need it to use some "whois" program to get some info from it.
But seems the better way is to code it myself, instead of using an external program.

Pofis

earl
Posts: 4
Joined: 2004-03-23 22:17

Post by earl » 2004-03-23 23:12

Ah, no. Use CreateProcess with CREATE_NO_WINDOW.

-earl-

Locked