Which of these is a correct way to initialize a pointer in C?Marks : 1Negative Marks : 0Answer hereint ptr = 0int *ptr = 0int ptr = NULLint *ptr = NULL

Question

Which of these is a correct way to initialize a pointer in C?Marks : 1Negative Marks : 0Answer hereint ptr = 0int *ptr = 0int ptr = NULLint *ptr = NULL
🧐 Not the exact question you are looking for?Go ask a question

Solution 1

The correct way to initialize a pointer in C is:

int *ptr = NULL;

Here's why:

  • int ptr = 0: This is incorrect because it's declaring an integer, not a pointer.
  • int *ptr = 0: This is technically correct, but it's not the best practice. In C, NULL is often used for pointers, not 0.
  • int ptr = N Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study prob
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solv

This problem has been solved

Similar Questions

Which of these is a correct way to initialize a pointer in C?Marks : 1Negative Marks : 0Answer hereint ptr = 0int *ptr = 0int ptr = NULLint *ptr = NULL

How is a null pointer represented in C?Marks : 1Negative Marks : 0Answer hereNULL0-11

Multi Choice Type QuestionHow is a null pointer represented in C?Marks : 1Negative Marks : 0Answer hereNULL0-11

ct the correct answerWhich of the following is the correct way to declare a pointer to an integer in C?Optionsinteger *ptr;ptr *int;int *ptr;point int *ptr;

he descriptive property possessed by each entity set is Marks : 1Negative Marks : 0Answer hereEntityAttributeRelationModel

1/3