Device Drivers Question:

Do you know what is the output of this program?

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
char *ptr;
memcpy(ptr,"google",11);
printf("%sn",ptr);
return 0;
}
a) google
b) segmentation fault
c) syntax error
d) none of the mentioned

Linux Device Drivers Interview Question
Linux Device Drivers Interview Question

Answer:

b) segmentation fault
Explanation:
Memory must be allocated to pointer "ptr".
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
Segmentation fault (core dumped)
[root@localhost google]#


Previous QuestionNext Question
This program will allocate the memory of ___ bytes for pointer "ptr".

#include<stdio.h>
#include<stdlib.h>

int main()
{
int *ptr;
ptr = realloc(0,sizeof(int)*10);
return 0;
}
a) 0
b) 10
c) 40
d) none of the mentioned
The connection between the device file and device driver is based on the:
a) name of device file
b) number of device file
c) both (a) and (b)
d) none of the mentioned