Why it doesn't work?

I want to change the size of one widget,below is my code:
unsigned short*width,*height;
*width=100;
PtSetResource(widget,Pt_ARG_WIDTH,&width,0);
*height=100;
PtSetResource(widget,Pt_ARG_HEIGHT,&height,0);

but it does’t work,why?

I use another way,
PtArg_t args[2];
args[0].type=Pt_ARG_WIDTH;
args[0].value=(long)100;
args[0].len=0;
args[1].type=Pt_ARG_HEIGHT;
args[1].value=(long)100;
args[1].len=0;
PtSetResources(widget,2,args);
it’s ok,but anyone can tell me why the first way can’t work?

That is wrong in so many ways…first, you are dereferencing pointers that don’t point to anything. Second, you are passing in a pointer to a pointer to an int when PtSetResource takes an init.

PtSetResource( widget, Pt_ARG_WIDTH, 100, 0 );
PtSetResource( widget, Pt_ARG_HEIGHT, 100, 0);

You only need to use a pointer when are getting the value out.

unsigned short *width;
PtGetResource( widget, Pt_ARG_WIDTH, &width, 0 );
if( width ) {
fprintf( stderr, “width is %d\n”, *width );
}

Never modify a resource via the pointer returned though, always copy it and use PtSetResource().