Linux Startup and Shutdown Question: Download Linux Shutdown & Startup PDF
In which condition this prgram will print the string "google"?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *ptr;
ptr = (int *)malloc(sizeof(int)*10);
if (ptr == NULL)
printf("googlen");
return 0;
}
a) if the memory could not be allocated to the pointer "ptr"
b) if the memory has been allocated to the pointer "ptr" successfully
c) it will never print
d) none of the mentioned
Answer:
a) if the memory could not be allocated to the pointer "ptr"
Explanation:
The malloc() returns NULL when the memory is not allocated.
Explanation:
The malloc() returns NULL when the memory is not allocated.