How to print int * & unsigned int* in NSLog?
63,029
Solution 1
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);
Solution 2
%@
is for objects. BOOL
is not an object. You should use %d
.
On the bases of data type %@
changes as follows
For Strings you use %@
For int you use %i
For float you use %f
For double you use %lf
Author by
HDdeveloper
Updated on June 24, 2020Comments
-
HDdeveloper about 4 years
How to print
int*
(int pointer) andunsigned int*
in log usingNSLog
?- (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 *'