NSInteger i = 42;
printf("%ld\n", (long)i);
In addition to the considerations mentioned in Table 2, there is one extra case with scanning: you must distinguish the types for float and double. You should use %f for float, %lf for double. If you need to use scanf (or a variant thereof) with CGFloat, switch to double instead, and copy the double to CGFloat.
1 CGFloat imageWidth;
2
3
4
double tmp;
sscanf (str, "%lf", &tmp);
imageWidth =tmp;
It is important to remember that %lf does not represent CGFloat correctly on either 32- or 64-bit platforms. This is unlike %ld, which works for long in all cases.