1 votes 1 votes Please tell me about all the variations of these above types of questions that can be asked? Programming in C programming-in-c + – Na462 asked May 4, 2018 Na462 731 views answer comment Share Follow See all 11 Comments See all 11 11 Comments reply Show 8 previous comments Arunav Khare commented May 4, 2018 reply Follow Share * is a de-referencing operator. *anyPtr would mean "go to the address pointed by anyPtr and then print value in it" In your case, a=(int *) 10 Address 10 in memory has nothing or is in your program's bounds. So, when you are getting segfault. 1 votes 1 votes srestha commented May 4, 2018 reply Follow Share yea, rt I think it is finding some hex value(as address are always in hex) and getting an integer value that is why giving seg fault 0 votes 0 votes gauravkc commented May 4, 2018 reply Follow Share I didn't get it @Arunav Khare .. The code srestha sent has no error. Are you getting confused between the two questions? Cause you are associating a line from her code to result of the code in the question @srestha .. The code u sent https://ideone.com/7rt9cz is not yet clear to me. I experimented a lot with that first line.. the code works fine even if u replace int* with float*, double* etc.. int a=(double*) 10; works but float a=(double*) 10; doesn't .. I guess it's ambiguous. @ankitgupta.1729 in the given question p will be assigned value 10.. When *p is printed, it causes segmentation fault as it's outside address space of it 1 votes 1 votes Please log in or register to add a comment.
1 votes 1 votes Refer these two link, these two posts are enough to understand about the pointers(some basic are required). Feel free to ask if you don't get something. https://stackoverflow.com/questions/5727/what-are-the-barriers-to-understanding-pointers-and-what-can-be-done-to-overcome?rq=1 https://stackoverflow.com/questions/18481740/pointer-expressions-ptr-ptr-and-ptr (examples like you asked in your question). bhuv answered May 5, 2018 bhuv comment Share Follow See all 0 reply Please log in or register to add a comment.