Quote:
Originally Posted by gasteven
- #include <stdio.h>
-
#include <string.h>
-
int main()
-
{
-
printf("%s\n", strerror(2));
-
return 0; /*indicates successful termination */
-
} /*end main*/
What is the above demonstrating?
Quote:
Originally Posted by gasteven
I put A and it was wrong! I like to know the right answer.
I assume the point of the question is to describe what
main does.
You need to familiarize yourself with standard library function
strerror. Your program creates the error message string corresponding to error number 2; and then prints that error message string to stdout.
Consider answer A:
a function takes an error number and creates an error message string. This is pretty close. Your program is hard coded for error number 2. Your program prints the error message string after creating it.
Consider answer B:
a function takes a string as an argument and returns the number of characters in the string. This can't be right because your function doesn't have any arguments.
Consider answer C:
a function copies the value of the byte and includes it as an error in the printf. This can't be right because the error number value ("2") is not present in the printed text.
Consider answer D:
none of the above. This is a possibility. It depends on whether the instructor considers the exceptions noted above for answer A to be significant.