little problem

hello everyone im new here in forums

i write a small function which call system to execute a command
the input is a ip address
which will send a command to ipblocker.exe to block the given ip

1
2
3
4
5
6
void autoblocknow(TCHAR* m_szIp)
{

	TCHAR* ip =m_szIp;
	 system("ipblocker.exe block=ip,255.255.255.255");
}


but i wont work =(
ip is not being sent to command
Last edited on
Does opening a command window and typing exactly ipblocker.exe block=ip,255.255.255.255 work?

That aside, this is not the best way to do this. Your operating system comes with decicated functions meant for just this sort of thing. Using system is expensive and its only advantage is its cross-platform capabilities. Since this code is inherently not cross-platform, relying on the existence of the program ipblocker, you can abandon system and use something better.

What operating system are you using? Windows provides the createprocess function; http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
im using windows

ipblocker.exe accepts commands like this
example:
ipblocker.exe block=192.168.1.1,255.255.255.255

function input is an ipaddress

my problem is the input ip is not being sent to command system like the sample above

system("ipblocker.exe block=ip,255.255.255.255");

ip is the input ip

im really sorry for poor explanation its my 1st week studying c++
Topic archived. No new replies allowed.