首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NSLog "const float *“

NSLog "const float *“
EN

Stack Overflow用户
提问于 2013-11-27 09:01:42
回答 1查看 929关注 0票数 1

快速问题:如何调试对象-C中const float *类型的常量中的值?

该对象在.h文件中声明如下:

代码语言:javascript
复制
const float *vertices;

尝试了%d (整数)、%@%f (双),但警告提示:

代码语言:javascript
复制
%@ , Format specifies type 'id' but the argument has type 'const float *'
%d , Format specifies type 'int' but the argument has type 'const float *'
%f , Format specifies type 'double' but the argument has type 'const float *'
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-27 09:03:45

您的意思是要打印它的值吗?

代码语言:javascript
复制
NSLog(@"%p: %f", vertices, * vertices);

这将在地址中打印其地址和浮动值。

正如@KenThomases建议的那样,如果不能保证,您可能需要检查vertices is NULL。并打印出vertices中的所有值

代码语言:javascript
复制
NSUInteger length = // length of vertices

for (NSUInteger i = 0; i < length; ++i) {
    NSLog(@"%f", vertices[i]);
}
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20237860

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档