V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  Gal3rielol  ›  全部回复第 1 页 / 共 2 页
回复总数  30
1  2  
2013-08-07 10:48:29 +08:00
回复了 itfanr 创建的主题 C C语言如何用指针的指针打印二维数组?
@xiaoye5200 既然你说指针的指针是对的又为什么要强转呢?
2013-08-07 00:01:57 +08:00
回复了 itfanr 创建的主题 C C语言如何用指针的指针打印二维数组?
@xiaoye5200 指针的指针是错误的, 不是没必要而是错误的.
2013-08-06 00:48:37 +08:00
回复了 itfanr 创建的主题 C C语言如何用指针的指针打印二维数组?
凡是用双重指针传参的全部都是错的
一维数组的类型int []可以视为为 int *
二维数组里面的数据元素的类型并不是int *;

我把代码贴上来
#include <stdio.h>

void pretty_print(int *start, int row, int col)
{
for (int i = 0; i < row; ++i) {
for (int j = 0; j < col; ++j) {
int *address = start + i * col + j; //手动计算地址
printf("%d ", *address);
}
printf("\n");
}
return;
}

int main(int argc, const char **argv)
{
int a[3][2] = {{1, 2}, {3, 4}, {5, 6}};
pretty_print((&a[0][0]), 3, 2);

int **p;
*p = &a[0]; //编译器会报类型不匹配的Warning

return 0;
}

2维数组在内存中也是线性的布局, 正确的做法是拿到第一个元素的地址手动计算剩下元素的地址.

clang报的warning如下
warning: incompatible pointer types assigning to 'int *' from
'int (*)[2]' [-Wincompatible-pointer-types]
*p = &a[0];
^ ~~~~~
可以看到 *p的类型是int *, 而
2013-07-13 19:12:29 +08:00
回复了 clowwindy 创建的主题 分享创造 知乎日报 - 比新闻更多
感觉不是很复杂的app, 但performance不是很好的样子, 主界面不是很流畅啊
2013-05-31 19:54:55 +08:00
回复了 mozartgho 创建的主题 程序员 对于王垠的这篇 “无谓的编辑器战争" 大家有什么看法?
@Golevka

不是parse,而是理解语义。
动态语言不带type annotation,做出IDE的那些功能很难,所以写ruby,python的时候用编辑器是可以的,因为根本没有好的IDE可以用。
而写Java,objc这种能用IDE却不用,非要用编辑器就...
在viewDidLoad:里面这么做


- (void)viewDidLoad
{
[super viewDidLoad];

//Do the stuff about tableview
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];

//Add a container view as self.view and the superview of the tableview
UITableView *tableView = (UITableView *)self.view;
UIView *containerView = [[UIView alloc] initWithFrame:self.view.frame];
tableView.frame = tableView.bounds;
self.view = containerView;
[containerView addSubview:tableView];

//add the view as a subview of the container view, it will be fixed on the top
UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
topView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
[self.view addSubview:topView];
}
2013-05-11 21:47:25 +08:00
回复了 undozen 创建的主题 程序员 可以再聊聊 emacs vs vim 吗?
所以你们对编辑器的认识只有他们移动cursor的快捷键不同么
2013-02-17 12:52:16 +08:00
回复了 PrideChung 创建的主题 iDev Xcode 4.6 的新功能
`真心希望Xcode能加强下Debug方面的功能,经常出现异常的时候只有一句毫无信息量的 "unrecognized selector sent to 0xxxxx", 要不就把你跳转到一堆看不懂也不会看的汇编代码。`

这就是你不会用了吧, 加一个异常断电就好了
2013-01-15 21:25:18 +08:00
回复了 Numbcoder 创建的主题 iDev 请教一个关于 NSData 的诡异问题
*range*
The range of bytes in the receiver's data to copy to buffer. The range must lie within the range of bytes of the receiver's data.

rang of bytes
2012-12-02 11:12:33 +08:00
回复了 Brutal 创建的主题 iDev 新手问几个关于 iOS 开发的问题
ARC和Manual性能比较时候采取的方法是什么, 直接说结论是没有说服力的.
2012-10-06 21:24:57 +08:00
回复了 pinkman 创建的主题 iDev "现实工作中"的国内iOS开发大多都是用c/c++在做吗?
Model部分用C/C++是无妨的

View和Controller这两部分不用Apple的框架, 呵呵厚
2012-08-09 14:12:31 +08:00
回复了 Livid 创建的主题 macOS 10.8 里的 Safari 很好用
@jjgod 请问如何让safari在single process模式下工作?
2012-07-25 20:21:36 +08:00
回复了 911 创建的主题 分享创造 MILKDAILY厂牌合作款通勤双肩电脑背包 召唤帖~
@911 你好, 现在这个包包还有优惠吗
2012-06-12 07:56:43 +08:00
回复了 Livid 创建的主题 iDev 似乎 iOS 6 的第一个 Beta 版里还没有包括 Passbook?
问一下系统的navibar的配色变了么,是不是换成iOS6图标的背景那种配色了?
另外iOS6用起来还算稳定吗...
2012-06-05 11:48:21 +08:00
回复了 manfay 创建的主题 机械键盘 趁着特价入手了cherry青轴键盘,说说使用感受
@thedevil7 外面那个壳子是蓝色的,别的没什么不同,貌似是买贵了=. =
2012-06-05 10:59:03 +08:00
回复了 manfay 创建的主题 机械键盘 趁着特价入手了cherry青轴键盘,说说使用感受
你们的poker青轴多少钱入的?
我刚花600入了一个兰博基尼版的,是不是贵了...
如果不使用nib,等同代码应该放在viewcontroller中的loadview:中。
并且view hierarchy就是应该在view controller中构建并控制的,比如说想让一个界面元素隐藏,这个工作明显应该让vc来做。

如果是刚接触这个平台,我推荐使用纯代码的方式构建界面,当对整个平台有一定的了解的时候再用interface builder.
1  2  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2454 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 29ms · UTC 08:38 · PVG 16:38 · LAX 01:38 · JFK 04:38
Developed with CodeLauncher
♥ Do have faith in what you're doing.