Aspire Faculty ID #12763 · Topic: JECA MCA 2023 · Just now
JECA MCA 2023

What is the output?

#include <stdio.h>
void main(){
  int **ptr;
  int temp = 65;
  ptr[0] = &temp;
  printf("%d", ptr[0][0]);
}

Solution

Explanation: The pointer ptr is uninitialized, so it does not point to valid memory. When the code tries to access ptr[0], it attempts to dereference an invalid location. This leads to undefined behavior, and in most cases results in a segmentation fault.

Previous 10 Questions — JECA MCA 2023

Nearest first

Next 10 Questions — JECA MCA 2023

Ascending by ID
Ask Your Question or Put Your Review.

loading...