C - Files and Preprocessors
C - Files and Preprocessors
52. Which of the following is valid for opening a read-only ASCII file ?
- fileopen (filenm, "read");
- fopen (filenm, "r");
- fileopen (filenm, "r");
- fopen (filenm, "read");
53. What are two predefined FILE pointers in C?
- stdout and stderr
- console and error
- stdout and stdio
- stdio and stderr
54. vaoid listfiele (FILE *f)
{
int C;
while ( C = fgetc( f ) ! = EOF)
{
printf ("%d",c);
}
printf ("\n");
}
What will be printed when the function above is called with pointer to an open file that contains the three characters abc ?
{
int C;
while ( C = fgetc( f ) ! = EOF)
{
printf ("%d",c);
}
printf ("\n");
}
What will be printed when the function above is called with pointer to an open file that contains the three characters abc ?
- The characters ab followed by an infinite number of c's
- 111
- abc
- 000
55. How could stderr be redirected from withing a program to force all error messages to be written to the end of the text file "error. log" instead of the location specified by the operating system ?
- stderr = fopen ( "error.log", "w");
- freopen ("error.log", "a", stderr);
- stderr = freopen (stderr, "a", "error.log");
- stderr = fopen ("errror.log", "a");
56. Which of the following would properly define a macro that doubled any expression passed to it ?
- # define DOUBLE (x ) x* 2
- # define DOUBLE (x) ((x)*);
- # define DOUBLE (x) (x) *2)
- # define DOUBLE (x) (x *2)
57. What will be the value of j in the following code ?
# define CATCH (a) a + 1
int i = 2;
int j = 4 * CATCH (I * 3);
# define CATCH (a) a + 1
int i = 2;
int j = 4 * CATCH (I * 3);
- 24
- 25
- 28
- 32
58. Which of the following preprocessor directives will make the system-dependent constant INT_MAX available for an ANSI Ccompiler ?
- # include
- # include
- # include
- # define INT_MAX
59. Which of the following is NOT a pre-processor directive ?
- # if
- # line
- # elseif
- #pragma
60. Which of the following is NOT a pre-processor directive ?
- # elif
- # pragma
- # line
- #exclude