gpt4 book ai didi

objective-c - 指针和循环

转载 作者:太空狗 更新时间:2023-10-30 04:01:33 26 4
gpt4 key购买 nike

这个问题已经困扰我一段时间了:这两者之间有区别吗(例如在内存方面)

Pointer *somePointer;
for (...)
{
somePointer = something;
// do stuff with somePointer
}

还有这个

for (...)
{
Pointer *somePointer = something;
// do stuff with somePointer
}

最佳答案

如果你想在完成循环后使用指针,你需要做第一个。

Pointer *somePointer;
Pointer *somePointer2;
for(loopA)
{
if(meetsSomeCriteria(somePointer)) break;
}

for(loopB)
{
if(meetsSomeCriteria(somePointer2)) break;
}
/* do something with the two pointers */
someFunc(somePointer,somePointer2);

关于objective-c - 指针和循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5052443/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com