Operating System - OpenVMS
1753301 Members
6783 Online
108792 Solutions
New Discussion

Re: system() call question

 
Joseph Huber_1
Honored Contributor

Re: system() call question

Fine, You now know that there are several ways in C to accomplish the same result.

Last week in another thread You learned already how to replace the series of strncat by a single sprintf :-)
http://www.mpp.mpg.de/~huber
Hoff
Honored Contributor

Re: system() call question

Here's a different answer to the homework.


#include
#include
#include

#define CMDBUFFERSIZE 512
static char cmdbuffer[CMDBUFFERSIZE+1];

main(int argc, char **argv )
{
int sts;
char *cmd = "mcr tcpip$snmp_trapsnd.exe 0.0 local 0 0 0 -h 10.100.18.245 -v2c 1.3.6.1.6.3.1.1.4.1.0 \"D\" \"%.*s\"";
sprintf( cmdbuffer, cmd, CMDBUFFERSIZE, argv[1] );
system( cmdbuffer );
}