-
:P Perhaps I should research more before I post. Anyway, here's where I'm at. I figured out what an Assertion failure is, but the _popen example (THE EXAMPLE!!) in MSVS 6 generates an error itself. Which makes me wonder.....
Anyway, I've stepped through and as far as I can tell, there is no way for this code to not generate an error. It tries to use a variable in fgets.c (FILE *str) in a check (_ASSERTE(str != null)) without ever initialising str to anything. That's what I understand from the code, anyway.
Is there any other way for me to get what "java -version" returns at command line in my program?
-
> fgets.c (FILE *str) in a check (_ASSERTE(str != null))
Yeah, it means the popen() failed.
Code:
FILE *fp = _popen("java -version", "r");
if ( fp == NULL ) {
perror( "Gotta problem" );
} else {
// rest of your code
}
-
Okaaayyyyy......so what do I do? No matter what I try, the _popen fails. Every time. Example code included. Does that mean I can't check the output of command line executions?
-
I dunno, does the perror() message actually tell you anything useful, like "why" it could not be completed?
-
I figured out that _popen only works for console apps. That's where the problem lies. :P