C中退出代码11的一般含义是什么?我环顾四周,无法找到明确的答案,所以我想我会在这里问.当我尝试向向量添加元素时.
所以我更新了我为游戏中心验证玩家的方式,我在启动时仍然遇到了崩溃.
这是我认证的新方式:
- (void) authenticateLocalPlayer
{
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
if (viewController != nil)
{
NSLog (@"user not logged in to GC");
}
else if ([GKLocalPlayer localPlayer].isAuthenticated)
{
NSLog(@"gamecenter authentication process succeeded");
}
else
{
NSLog(@"user not authenicated");
}
};
}
Run Code Online (Sandbox Code Playgroud)
这是崩溃时显示的内容:
2014-11-12 16:20:43.295 ZombieConga[7492:881764] -[GKLocalPlayerInternal name]: unrecognized selector sent to instance 0x7974b8c0
2014-11-12 16:20:43.298 ZombieConga[7492:881764] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GKLocalPlayerInternal name]: unrecognized selector sent to instance 0x7974b8c0' …Run Code Online (Sandbox Code Playgroud) 如何调用c中的随机数生成器,在调用函数时给出不同的数字.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
printf("%i",num());
printf("%i",num());
}
int num() {
int MAX = 100;
srand ( time(NULL));
int num = rand() % MAX;
return num;
}
Run Code Online (Sandbox Code Playgroud)
无论我调用num函数多少次,它总是打印相同的数字.我如何解决这个问题,因此每次通话的号码都不同.