Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

does this onlie GDB can handle double pointer

0 votes
asked Aug 18, 2019 by Jongbo (470 points)
i was studying double pointer and i couldnt find error on this code but it was keep givng segmantation fault error so can someone help me with this

#include <stdio.h>
#include "malloc.h"

void main()
{
 short **pp,data=3;
 int my_ptr = (int)&data;
 pp = (short**)&my_ptr;
 **pp=5;
 printf("data: %d",data);
    
}

2 Answers

0 votes
answered Aug 20, 2019 by SWEngineer
Your typing is faulty. my_ptr is not a pointer. Also, you mix int and short. I suggest you get a better C book.
commented Aug 21, 2019 by Jongbo (470 points)
THank you for your answer. but my book was trying to explain about having double pointer with two other variable. and usage of them . like pp box can point to my_ptr and data. but my ptr cannot point to data. and converting data type during it...
0 votes
answered Aug 22, 2019 by anonymous
my_ptr undeclared as a pointer - missing *.

Prints 3:

#include <stdio.h>

void main()
{
 short **pp,data=3;
 int *my_ptr = (int)&data;
 pp = (short**)&my_ptr;
 //pp=5;
 printf("data: %d",data);
    
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...