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.

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.