0

6b87dfe9bac7df6c309f7266d28a4ad0
i am reading "pointers in c by naveen toppo" .According to him program crashes when it encounter

int y=*ptr;

i dont understand why it should crash?i think its correct. *ptr gives int value.
please refer attachement.

2
Contributors
1
Reply
16
Views
2 Years
Discussion Span
Last Post by Ancient Dragon
0

Post your code, the diagram you posted is not very helpful to find the problem in your program. My guess is that the pointer you used was not initialized to a specific address before dereferencing it. For example

int k = 123; // original integer
int* p = &k; // initialize a pointer
int q = *p;  // dereference the pointer

Edited by Ancient Dragon

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.