Código:
Pero no consigo que fgets recupere nada. #include <stdlib.h> #include <iostream> int main (int argc, char *argv[]){ FILE *chkdsk; const int MAX_BUFFER = 2048; char buffer[MAX_BUFFER]; chkdsk = _popen( "java -version", "rt" ); if (chkdsk == NULL) perror ("Error al ejecutar el comando"); else{ while( !feof( chkdsk ) ){ a++; if( fgets( buffer, MAX_BUFFER, chkdsk ) != NULL ){ puts(buffer); }else{ printf("\nfgets no recupero nada\n"); } }//While }//else system("pause"); fclose(chkdsk); return 0; }