I have the following code for linux:
char pi[512];
FILE *fp1;
char pingStr[250];
sprintf(pingStr, "ping %s", info->server);
fp1 = popen(pingStr,"r");
fgets(pi,512,fp1);
fgets(pi,512,fp1);
Send("%s\r\n",pi); //my function
fclose(fp1);
Is there a Windows equivalent? Because I could not seem to get it too work.
What I am trying to do is to pipe the output of the Windows ping
command into a buffer to send to my function.
The code snipped you have provided is extremely simple, so there are Windows equivalents for all of the functions you have used. Here they are with documentation:
The difference that can lead to error could be in library name you have to link with, function name (starting with _
sometimes), header file name, include path or other. It is hard to tell exactly what error you experience and why, unless you provide enough details.
Other than that, everything should work as in Linux.