質問

This is a little problem I am having, and although it seems to be basic and simple I cannot find it out, here is the code:

int main (int argc, const char * argv[]) {
    unsigned long long ep  = 2292674165ul;
    unsigned long long ep2 = 2487148347ul;
    NSLog(@"%u", ep );
    NSLog(@"%u", ep2);
    NSLog(@"%u %u", ep , ep2);
    // a last try..
    NSLog(@"%@",[NSString stringWithFormat:@"%u %u", ep , ep2]);
}

Its output:

2013-02-14 13:26:15.968 FTPTests[5274:1307] 2292674165
2013-02-14 13:26:15.970 FTPTests[5274:1307] 2487148347
2013-02-14 13:26:15.971 FTPTests[5274:1307] 2292674165 0
2013-02-14 13:26:15.972 FTPTests[5274:1307] 2292674165 0

Can someone tell me why the second specifier is printing 0? How can I solve it?

Thanks!

役に立ちましたか?

解決

Try to use %llu instead of %u.

他のヒント

I believe you're using the incorrect format specifier try using %llu. The compilers warns you when you compile it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top