A
aarklon
Hi all,
I was going through the book "Test your skills in C" by Thamarai selvi
and R murugesan, publisheb by Tata Mcgraw-Hill,
ISBN 0-07-044759-4 , the following are from this book,
now my question is to what extent the following are true..???
1) a function with no action is allowed and is known as dummy function
2) (int(*(*)[3])(char*))ptr is the correct way to cast ptr to a
pointer to a 3 element array of function pointers with a return value
of int and a single parameter of a pointer to char
3)how could stderr be re directed from within a program to force all
error messages to be written to the end of the text file "error.log"
instead of location specified by the operating system
a) stderr = fopen("error.log","w");
b) freopen("error.log","a",stderr);
c) stderr = freopen(stderr,"a","error.log");
d) stderr = fopen("error.log","a");
the answer is given as d option
4) #include<stdlib.h>
#include <stdio.h>
char *format="%d";
void func();
int main(void)
{
int x;
func(scanf,&x);
printf("%d\n",x);
return EXIT_SUCCESS;
}
referring to the sample code given above, which of the following
would be correct implementation
for func ?
a) void func( int (*y)(const char*,...),int* x)
{ (*y)(format,x); }
b) void func( int (*y)(const char*,...),int* x)
{ (*y)(format,&x); }
answer is given as a option
I was going through the book "Test your skills in C" by Thamarai selvi
and R murugesan, publisheb by Tata Mcgraw-Hill,
ISBN 0-07-044759-4 , the following are from this book,
now my question is to what extent the following are true..???
1) a function with no action is allowed and is known as dummy function
2) (int(*(*)[3])(char*))ptr is the correct way to cast ptr to a
pointer to a 3 element array of function pointers with a return value
of int and a single parameter of a pointer to char
3)how could stderr be re directed from within a program to force all
error messages to be written to the end of the text file "error.log"
instead of location specified by the operating system
a) stderr = fopen("error.log","w");
b) freopen("error.log","a",stderr);
c) stderr = freopen(stderr,"a","error.log");
d) stderr = fopen("error.log","a");
the answer is given as d option
4) #include<stdlib.h>
#include <stdio.h>
char *format="%d";
void func();
int main(void)
{
int x;
func(scanf,&x);
printf("%d\n",x);
return EXIT_SUCCESS;
}
referring to the sample code given above, which of the following
would be correct implementation
for func ?
a) void func( int (*y)(const char*,...),int* x)
{ (*y)(format,x); }
b) void func( int (*y)(const char*,...),int* x)
{ (*y)(format,&x); }
answer is given as a option