Skip to content

Instantly share code, notes, and snippets.

@pjc0247
Created January 26, 2015 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjc0247/cadcbe61c7f2130cd226 to your computer and use it in GitHub Desktop.
Save pjc0247/cadcbe61c7f2130cd226 to your computer and use it in GitHub Desktop.
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
int main(int argc, char* argv[]){
FILE *fp = _popen("dir", "r");
std::string buffer;
while(true){
char b[256] = {0};
fread(b, _countof(b)-1, 1, fp);
buffer.append(b);
if(feof(fp)) break;
}
printf("%s", buffer.c_str());
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment