小编iPa*_*rJr的帖子

访问Objective-C中的命令行参数

是否有完整的文档(该接口是目前在crt_externs.h)这个功能: _NSGetArgc_NSGetArgv 我不能让苹果网站这个功能上的任何文件.

cocoa objective-c command-line-arguments

37
推荐指数
3
解决办法
2万
查看次数

二进制编码十进制(BCD)到十六进制转换

谁能向我解释如何将BCD转换为十六进制?例如,我如何将98(BCD)转换为十六进制.谢谢.

hex bcd

7
推荐指数
2
解决办法
7万
查看次数

矢量和链接列表ADT之间的差异

有人可以向我解释在交互式编程语言环境中Vector和Linked List ADT之间的区别.

谢谢.

c linked-list vector adt data-structures

3
推荐指数
1
解决办法
4926
查看次数

在Objective-c中将发布发送到NIL

有人可以在mac计算机上然后在iphone设备上向我解释这个程序的输出.

我创建了一个不含任何东西的普通Foo类,Foo.h:

#import <Foundation/Foundation.h>

@interface Foo : NSObject {

}

@end
Run Code Online (Sandbox Code Playgroud)

和Foo.m:

#import "Foo.h"

@implementation Foo

@end
Run Code Online (Sandbox Code Playgroud)

要在Mac上测试它,我使用这个main.m:

#import "Foo.h"

int main(int argc, const char *argv[]) {

  NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    Foo *myFoo; 

    [myFoo description];
    printf("%p\n", myFoo);
    [myFoo release];

    [pool drain];

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

这个程序输出:

0x0
Run Code Online (Sandbox Code Playgroud)

但是在iphone上它会直接崩溃.

谢谢.

iphone macos null memory-management

0
推荐指数
1
解决办法
1593
查看次数

将char缓冲区转换为ac结构

在下面的代码中我期待另一个输出!:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _cust {
        char    customerId[10];
        char    customerPhone[10];
        char    customerDep[4];
} cust;

int main(int argc, char **argv) {
        cust    *newCust;
        const char testChar[] = "11W35A5CT-012345678-CORP";

        newCust = (cust *)malloc(sizeof(struct _cust));
        newCust = (cust *)testChar;

        printf("CustomerId = %s\n", newCust->customerId);
        printf("CustomerPhone = %s\n", newCust->customerPhone);
        printf("CustomerDep = %s\n", newCust->customerDep);

        return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出是:

CustomerId = 11W35A5CT-012345678-CORP
CustomerPhone = 012345678-CORP
CustomerDep = CORP
Run Code Online (Sandbox Code Playgroud)

我期待这个输出:

CustomerId = 11W35A5CT-
CustomerPhone = 012345678-
CustomerDep = CORP
Run Code Online (Sandbox Code Playgroud)

有人能解释一下为什么这样吗?谢谢.

编辑:

为了避免混淆我的帖子,我在调试这个程序时在这里添加了gdb跟踪:

(gdb) …
Run Code Online (Sandbox Code Playgroud)

c struct casting

0
推荐指数
1
解决办法
4978
查看次数