LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Is solution for control "NaN" and "Inf" in C/C++ (https://www.linuxquestions.org/questions/programming-9/is-solution-for-control-nan-and-inf-in-c-c-30702/)

gmitra 09-19-2002 08:24 AM

Is solution for control "NaN" and "Inf" in C/C++
 
Hi,
i have very easy question which your answer
can solve big my problem. is there any solution
how to control error outputs of function printf
or fprintf in C/C++?
Thx.
With regards,
Martin Gmitra.

TheLinuxDuck 09-19-2002 08:31 AM

Are you refering to errors that occur from the use of printf or fprintf during runtime of an application? Or, are you refering to syntactic mistakes during the coding progress that result in errors during compilation? Or, to the actual output they provide during runtime from a legitimate call?

I can only assume for the moment that you're refering to the 3rd one. If you need the output to go to the standard error buffer, simply use fprintf as:
Code:

fprintf(stderr, "Could not do that: %s\n", reasonString);
If I am misunderstanding, please explain, and possibly post the section of code that is causing the problem.

gmitra 09-19-2002 08:57 AM

Oh sorry, you are right. I misunderstand you. Here is
example:

fprintf(f_out,"%e\n",log(-1.0));

produces output "Inf" because log function is defined
for positive number without zero.
In some reasons i have got "NaN". i want to get info
during the runtime about this and regulate the output.
Thx.
Martin Gmitra.


All times are GMT -5. The time now is 04:36 PM.