What is the output of this program? [code] #include<stdio.h> #include<stdlib.h> #include<string.h>

Đăng Khánh

New member
What is the output of this program?
Code:
    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>                              
    int main()
    {
        int ptr;
        ptr = (int)malloc(sizeof(int)*10);
        return 0;
    }
A. syntax error
B. segmentaion fault
C. run time error
D. none of the mentioned
 
Answer: d
Explanation: The memory has been allocated but we can not access rest of the memory other than 4 bytes.
Output:
[root@localhost 123hoidap]# gcc -o san san.c
[root@localhost 123hoidap]# ./san
[root@localhost 123hoidap]#
 

Tìm kiếm

Back
Top