> From: owner-openssl-us...@openssl.org On Behalf Of Akanksha Shukla > Sent: Monday, 31 October, 2011 08:48 <snip> > { > FILE * pFile1; > char mystring [500]; > pFile1 = fopen ("result.txt","a"); > if (pFile1!=NULL) > { > ERR_print_errors_fp(stderr); > if ( fgets (mystring , 500 , stderr) != NULL ) > { > fputs (mystring, pFile); > } > fclose(pFile1); > } <snip> > And also tried this one, but no luck. <snip: same thing but no if() on fgets return>
These will never work. First of all, there's no promise you can read from stderr (or stdout) at all. Even on systems and in situations (e.g. redirection) where you can read, you have to fseek or fsetpos first (or fflush if you are already positioned, which here you aren't). The approach I thought you had before, if( pFile1 != NULL ) ERR_print_errors_fp (pFile1) should work assuming the fopen succeeded. Could 'results.txt' be a pre-existing file that is not writable? (If this code is part of a bigger program/process, is everything run and owned by your userid, or is it more complicated?) I suggest divide and conquer -- just call ERR_print_errors_fp(stdout) You won't get the info to the file where you may want it, but you should get it somewhere you can see, assuming you are seeing the other cout<< stuff. And printf or cout<< retVal, just to make sure what it is. Then you can figure out writing to a file. Even if you get hex codes instead of friendly strings, because you didn't _load_error_strings, it's still better than nothing. You can decode them with commandline errstr. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org