Skip to content

Instantly share code, notes, and snippets.

@Kwpolska
Created March 10, 2013 12:12
Show Gist options
  • Save Kwpolska/5128331 to your computer and use it in GitHub Desktop.
Save Kwpolska/5128331 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
int print_error(int errorcode) {
FILE *fp;
char cmd[100];
char out[1000];
sprintf(cmd, "NET HELPMSG %d'", errorcode);
fp = popen(cmd, "r");
while (fgets(out, sizeof(out)-1, fp) != NULL) {
/* replace *** with service name here; I’m too lazy to write that here because C doesn’t have easy string replacement AFAIK, and if it doesn’t, share a link. */
printf("%s", out);
}
pclose(fp);
printf("\nLess help is available by typing NET HELPMSG %d.\n\n\n", errorcode);
return 0;
}
int main() {
print_error(3521);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment