New to C programming. I am writing a web application that should use several ansi C functions to compress data. Another language, possibly Java, will call the main C function to invoke the process. I want to return a value from the main C function for a Java script to measure success or not. I expect that use of exit () was created for this.
As I do C programming, I come across several situations that I could evaluate to check if the program is working correctly. For example, if I have a variable that can only be equal to “equation 1”, “equation 2” or “equation 3”, then I use the operator if {} else if {} else if {} to check which of the three perhaps I could add else {} to the end, whose contents that I expect will never be executed in a normally running program to catch unexpected problems. I want to put exit(EXIT_FAILURE)in this last {} statement. If I understand it correctly, this will lead to the termination of the program and the return of a nonzero value to the calling Java program to detect it. It is right?
Is it possible to color this output (EXIT_FAILURE) for different functions, and not just for main () for the same reason?
Some questions about the mechanism for setting this parameter. Is the main function just configured as: int main(void);without allowing input arguments for simplicity? That is, int is needed to return the integer value called by the EXIT_FAILURE macro ... is this correct?
If the main () function called another function, and this function contained an operator exit(EXIT_FAILURE), should this other function specifically include a return in its prototype, for example. int function_one(void);, where int is necessary to return the status of EXIT_FAILURE or the macro EXIT_FAILURE in this regard, therefore, if function_ better wants to return, say, a character, then its prototype may not have to char function_one(void);worry about returning something for EXIT_FAILURE in its prototype?
source
share