How to print int * & unsigned int* in NSLog?

HDdeveloper picture HDdeveloper · Jan 18, 2013 · Viewed 60.2k times · Source

How to print int* (int pointer) and unsigned int* in log using NSLog?

- (int) doSomethingWith:(unsigned int)Msg withWparam:(unsigned int*)wParam withParameter:(int *) lParam
{
    NSLog(@"MSg:%d wParam:%u lParam:%u",Msg,wParam,lParam);
//not working
    return 1;
}

Warning: Format specifies type 'unsigned int' but the argument has type 'unsigned int *'

Answer

Joris Kluivers picture Joris Kluivers · Jan 18, 2013

Use %d for int. And the parameters are pointers, so use * to access the values pointed to.

NSLog(@"MSg:%d wParam:%u lParam:%d",Msg,*wParam,*lParam);