Hi, I have a question and I don't know how stderr from the stdio.h library and fprintf() from string.h are used . For example I have this:
fprintf(stderr, "Error en planta de Centro: %d\n", numeroPlantas);
Where numberPlants is an int . I would like you to clarify when they are usually used and their meaning if possible.
fprint I don't think you'll have a problem knowing that, it allows the output of printf to be written to any file.
stderr is a way to print the errors, stderr contains the possible errors that the user wants to report .
Here is a documentation in Spanish
as an example:
It has as output:
When you run a program, the output you see on the console is usually a combination of stdout and stderr. But it is possible to redirect both outputs to different files.
So if you run "./myprogram 1>log 2>errorLog" you will get everything you print to stderr in errorlog and not in log. This is assuming that the Operating System associates 0 with stdin, 1 with stdout and 2 with stderr, which is normal.