What is the output of this program? [code] #include<stdio.h> int main() { int *ptr; ptr = (int *)calloc(1,sizeof(int));

Julipkq

New member
What is the output of this program?
Code:
   #include<stdio.h>
   int main()
   {
       int *ptr;
       ptr = (int *)calloc(1,sizeof(int));
       *ptr = 10;
       printf("%d\n",*ptr);
       return 0;
   }
A. 0
B. -1
C. 10
D. none of the mentioned
 
Answer: d
Explanation: This program will give an error because calloc() requires the header file stdlib.h.
Output:
[root@localhost 123hoidap]# gcc -o san san.c
san.c: In function ‘main’:
san.c:6:15: warning: incompatible implicit declaration of built-in function ‘calloc’ [enabled by default]
[root@localhost 123hoidap]#
 

Tìm kiếm

Back
Top